-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrinContentScript.js
More file actions
35 lines (33 loc) · 1 KB
/
Copy pathtrinContentScript.js
File metadata and controls
35 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function isAlreadyLoaded() {
if(window.hasOwnProperty('trinUI')) {
return true;
}
const jscripts = document.getElementsByTagName('script');
for(const jscript of jscripts) {
if(jscript.id === 'trinScript' || jscript.src.includes('trinUI.js')) {
return true;
}
}
return false;
}
function importAndInitUI() {
const trinPath = chrome.runtime.getURL("trinUI.js");
import(trinPath).then((trinUI) => {
window.trinUI = trinUI;
window.trin = trinUI.trin;
const foundScripts = trinUI.trin.detectScripts(document.body.innerText);
if(foundScripts.size > 0) {
console.log('trin detected', Array.from(foundScripts).map((script) => script.name).join(', '));
}
else {
console.log("trin didn't find any Indian scripts.");
}
trinUI.loadUI(chrome.storage.local, 'extension');
});
}
if(isAlreadyLoaded()) {
console.log('trin already loaded.');
}
else {
importAndInitUI();
}