Skip to content

Commit

Permalink
feat: watermark style csp
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Jan 10, 2025
1 parent b64c764 commit 565a643
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/water-mark/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"zh": "🔥🔥🔥移除页面水印🔥🔥🔥"
},
"namespace": "https://github.com/WindrunnerMax/TKScript",
"version": "1.0.5",
"version": "1.0.6",
"description": {
"default": "移除常见网页的水印",
"en": "Remove watermarks from common web pages",
Expand All @@ -17,5 +17,5 @@
"license": "GPL License",
"installURL": "https://github.com/WindrunnerMax/TKScript",
"run-at": "document-start",
"grant": ["unsafeWindow"]
"grant": ["GM_addStyle", "unsafeWindow"]
}
2 changes: 2 additions & 0 deletions packages/water-mark/src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ declare module "*.css" {
const content: string;
export default content;
}

declare const GM_addStyle: (css: string) => void;
8 changes: 6 additions & 2 deletions packages/water-mark/src/utils/styles.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { styles } from "../../../copy-currency/src/utils";

export const injectCSSEarly = (css: string) => {
if (typeof GM_addStyle === "function") {
GM_addStyle(css);
return void 0;
}
const style = document.createElement("style");
style.innerText = css;
const head = document.head;
if (head) {
head.appendChild(style);
return;
return void 0;
}
const html = document.documentElement;
if (html) {
html.appendChild(style);
return;
return void 0;
}
styles.insertCSS(String(Math.random()), css);
};

0 comments on commit 565a643

Please sign in to comment.