generated from KyuubiRan/EzXHepler-template
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathCSP.user.js
31 lines (29 loc) · 1.04 KB
/
CSP.user.js
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
// ==UserScript==
// @name Content-Security-Policy Blocker
// @namespace JingMatrix
// @match https://*
// @run-at document-start
// @grant GM_registerMenuCommand
// ==/UserScript==
const cspRule = localStorage.getItem("CSPBlocker");
if (cspRule) {
const meta = document.createElement("meta");
meta.setAttribute("http-equiv", "Content-Security-Policy");
meta.setAttribute("content", cspRule);
try {
document.head.append(meta);
} catch {
setTimeout(() => {
document.head.append(meta);
}, 0);
}
}
GM_registerMenuCommand("No JavaScript", () => { localStorage.setItem("CSPBlocker", "script-src 'none'") });
GM_registerMenuCommand("No Third-Party", () => { localStorage.setItem("CSPBlocker", "default-src 'unsafe-inline' 'self'") });
GM_registerMenuCommand("Edit CSP rules", () => {
const newrule = prompt("Editing CSP rules", localStorage.getItem("CSPBlocker") || "");
if (newrule && newrule != "") {
localStorage.setItem("CSPBlocker", newrule)
}
});
GM_registerMenuCommand("Clear CSP rules", () => { localStorage.removeItem("CSPBlocker") });