|
@@ -103,7 +103,44 @@ chrome.storage.sync.get('userInfo', function(data) {
|
|
|
if (dataTempCopy.style || dataTempCopy.script) {
|
|
if (dataTempCopy.style || dataTempCopy.script) {
|
|
|
dataTempCopy.style = dataTempCopy.style || '[]'
|
|
dataTempCopy.style = dataTempCopy.style || '[]'
|
|
|
dataTempCopy.script = dataTempCopy.script || '[]'
|
|
dataTempCopy.script = dataTempCopy.script || '[]'
|
|
|
- chrome.tabs.executeScript(dataTemp.tabInfo.id, {code: unescape(dataTempCopy.data)})
|
|
|
|
|
|
|
+ let temp = `
|
|
|
|
|
+ function loadScript(url, callback) {
|
|
|
|
|
+ var script = document.createElement("script")
|
|
|
|
|
+ script.type = "text/javascript";
|
|
|
|
|
+ if (script.readyState) { //IE
|
|
|
|
|
+ script.onreadystatechange = function () {
|
|
|
|
|
+ if (script.readyState == "loaded" || script.readyState == "complete") {
|
|
|
|
|
+ script.onreadystatechange = null;
|
|
|
|
|
+ if (callback) callback();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ } else { //Others
|
|
|
|
|
+ script.onload = function () {
|
|
|
|
|
+ if (callback) callback();
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ script.src = url;
|
|
|
|
|
+ var head = document.head || document.getElementsByTagName('head')[0];
|
|
|
|
|
+ head.appendChild(script);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function loadCSS (url) {
|
|
|
|
|
+ var link = document.createElement("link");
|
|
|
|
|
+ link.rel = "stylesheet";
|
|
|
|
|
+ link.type = "text/css";
|
|
|
|
|
+
|
|
|
|
|
+ link.href = url;
|
|
|
|
|
+
|
|
|
|
|
+ document.getElementsByTagName("head")[0].appendChild(link);
|
|
|
|
|
+ }
|
|
|
|
|
+ ${dataTempCopy.style}.forEach(element => {
|
|
|
|
|
+ loadCSS(element)
|
|
|
|
|
+ });
|
|
|
|
|
+ ${dataTempCopy.script}.forEach(element => {
|
|
|
|
|
+ loadScript(element)
|
|
|
|
|
+ });
|
|
|
|
|
+ `
|
|
|
|
|
+ chrome.tabs.executeScript(dataTemp.tabInfo.id, {code: unescape(temp)})
|
|
|
}
|
|
}
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|