Skip to content

Commit

Permalink
fix GM_addStyle() quoid#194 quoid#195
Browse files Browse the repository at this point in the history
  • Loading branch information
quoid committed Jan 8, 2022
1 parent 36a326a commit 030856b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions extension/Userscripts Extension/Resources/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,8 @@ function deleteValue(key) {
}

function addStyleSync(css) {
browser.runtime.sendMessage({name: "API_ADD_STYLE_SYNC", css: css});
window.postMessage({id: uid, name: "API_ADD_STYLE_SYNC", css: css});
return css;
// try {
// const tag = document.createElement("style");
// tag.textContent = css;
// document.head.appendChild(tag);
// return css;
// } catch (e) {
// console.log(e);
// }
}

function addStyle(css) {
Expand Down Expand Up @@ -509,6 +501,14 @@ window.addEventListener("message", e => {
} catch (e) {
console.log(e);
}
} else if (name === "API_ADD_STYLE_SYNC") {
console.log("SYNC");
try {
message = {name: "API_ADD_STYLE_SYNC", css: e.data.css};
browser.runtime.sendMessage(message);
} catch (e) {
console.log(e);
}
} else if (name === "API_XHR_INJ") {
message = {name: "API_XHR_CS", details: e.data.details, xhrId: e.data.xhrId};
browser.runtime.sendMessage(message, response => {
Expand Down

0 comments on commit 030856b

Please sign in to comment.