Skip to content

Commit 565a643

Browse files
committed
feat: watermark style csp
1 parent b64c764 commit 565a643

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/water-mark/meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"zh": "🔥🔥🔥移除页面水印🔥🔥🔥"
66
},
77
"namespace": "https://github.com/WindrunnerMax/TKScript",
8-
"version": "1.0.5",
8+
"version": "1.0.6",
99
"description": {
1010
"default": "移除常见网页的水印",
1111
"en": "Remove watermarks from common web pages",
@@ -17,5 +17,5 @@
1717
"license": "GPL License",
1818
"installURL": "https://github.com/WindrunnerMax/TKScript",
1919
"run-at": "document-start",
20-
"grant": ["unsafeWindow"]
20+
"grant": ["GM_addStyle", "unsafeWindow"]
2121
}

packages/water-mark/src/types/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ declare module "*.css" {
44
const content: string;
55
export default content;
66
}
7+
8+
declare const GM_addStyle: (css: string) => void;
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { styles } from "../../../copy-currency/src/utils";
22

33
export const injectCSSEarly = (css: string) => {
4+
if (typeof GM_addStyle === "function") {
5+
GM_addStyle(css);
6+
return void 0;
7+
}
48
const style = document.createElement("style");
59
style.innerText = css;
610
const head = document.head;
711
if (head) {
812
head.appendChild(style);
9-
return;
13+
return void 0;
1014
}
1115
const html = document.documentElement;
1216
if (html) {
1317
html.appendChild(style);
14-
return;
18+
return void 0;
1519
}
1620
styles.insertCSS(String(Math.random()), css);
1721
};

0 commit comments

Comments
 (0)