summaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorhackademix2019-10-18 22:43:08 +0200
committerhackademix2019-10-18 22:43:08 +0200
commit1ead91d2aa0e9029327c3e0817d51f03777b31ae (patch)
tree9d84f2788124884e496db960d5b38c029a5646ed /src/content
parent1e88b30a209d345240d28d0adb8a28f34ddd889a (diff)
downloadnoscript-1ead91d2aa0e9029327c3e0817d51f03777b31ae.tar.gz
noscript-1ead91d2aa0e9029327c3e0817d51f03777b31ae.tar.xz
noscript-1ead91d2aa0e9029327c3e0817d51f03777b31ae.zip
Support for safe asynchronous page loading without fallback reloads.
Diffstat (limited to 'src/content')
-rw-r--r--src/content/staticNS.js25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/content/staticNS.js b/src/content/staticNS.js
index e5aaf3c..a175220 100644
--- a/src/content/staticNS.js
+++ b/src/content/staticNS.js
@@ -55,36 +55,25 @@
let url = document.URL;
let isFileUrl = url.startsWith("file:");
if (isFileUrl) {
- let cookie = "noscript.startupFileReloaded=true";
- if (!document.cookie.split(/\s*;\s*/).includes(cookie)) {
- stopAndReload(() => document.cookie = cookie);
- }
+ addEventListener("beforescriptexecute", e => {
+ if (!this.canScript) e.preventDefault();
+ }, true);
}
let policy = browser.runtime.sendSyncMessage(
{id: "fetchPolicy", url, contextUrl: url});
debug("Fetched %o, readyState %s", policy, document.readyState);
- if (!policy) {
- debug("Could not fetch policy!");
- if (isFileUrl && !sessionStorage.__noScriptFallbackReload__) {
- sessionStorage.__noScriptFallbackReload__ = "true";
- stopAndReload();
- }
- // let's try asynchronously
- (async () => {
- this.setup(await Messages.send("fetchPolicy", {url, contextUrl: url}));
- })();
- return false;
- } else if (policy.fallback) {
- stopAndReload();
- }
this.setup(policy);
+
return true;
},
setup(policy) {
debug("%s, %s, %o", document.URL, document.readyState, policy);
+ if (!policy) {
+ policy = {permissions: {capabilities: []}, localFallback: true};
+ }
this.policy = policy;
if (!policy.permissions || policy.unrestricted) {