-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- service worker shuts down every 5 minutes (more or less works) - extension doesn't work until you open the pop-up - customize cURL timeouts
- Loading branch information
Showing
13 changed files
with
207 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
font-size: 16px; | ||
} | ||
|
||
#line1, #line2 { | ||
#line1, | ||
#line2 { | ||
width: 100%; | ||
height: 50%; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,61 @@ | ||
import { getLocalStorage, setLocalStorage } from 'utils/chrome/storage'; | ||
import { onMessage } from 'utils/chrome/runtime'; | ||
import { onMessage, onInstalled, getAll, getManifest, executeScript, insertCSS } from 'utils/chrome/runtime'; | ||
import defaults from './defaults'; | ||
|
||
onMessage(async (request) => { | ||
const id = request.id; | ||
const value = request.value; | ||
|
||
if (id == 'analytics') { | ||
const data = await getLocalStorage(id); | ||
data[value] += 1; | ||
setLocalStorage(id, data); | ||
} | ||
}, true); | ||
}); | ||
|
||
async function setDefaultSettings() { | ||
const config = defaults; | ||
|
||
for (const option in config) { | ||
if ((await getLocalStorage(option)) !== undefined) { | ||
continue; | ||
} | ||
|
||
setLocalStorage(option, config[option]); | ||
} | ||
} | ||
|
||
async function init() { | ||
await setDefaultSettings(); | ||
|
||
const navigatorWindows = await getAll(); | ||
const contentScripts = getManifest().content_scripts[0]; | ||
const match = contentScripts.matches[0].replaceAll('*', '.*').replaceAll('/', '\\/'); | ||
const regex = new RegExp(match); | ||
const js = contentScripts.js[0]; | ||
const css = contentScripts.css[0]; | ||
|
||
navigatorWindows.forEach((window) => { | ||
for (const tab of window.tabs) { | ||
if (!regex.test(tab.url)) { | ||
continue; | ||
} | ||
|
||
executeScript({ | ||
target: { | ||
tabId: tab.id, | ||
}, | ||
files: [js], | ||
}); | ||
|
||
insertCSS({ | ||
target: { | ||
tabId: tab.id, | ||
}, | ||
files: [css], | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
onInstalled(init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const defaults = { | ||
captions: true, | ||
subtitlesActivated: false, | ||
'curent-path': '', | ||
'auto-translate': true, | ||
'created-translations': true, | ||
'primary-language': 'Spanish#es', | ||
'server-translate': 'Deepl*#deepl', | ||
'time-close-translation': 3, | ||
translateTo: 'English#en', | ||
analytics: { | ||
'translated-words': 0, | ||
}, | ||
timeKeepAlive: 240, | ||
}; | ||
|
||
export default defaults; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.