summaryrefslogtreecommitdiff
path: root/data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2019-05-10 19:05:20 -0400
committerRuben Rodriguez <ruben@gnu.org>2019-05-10 19:05:20 -0400
commit7859a9131fcda359265dc16ef55933e5ed218119 (patch)
treeecb4bf7a0fd005a637d3ff0444ce9afaa8817ba9 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js
parentcb4bbb16a12d495eca1ac05ebacc7557e9b05c05 (diff)
Updated extensions bundle
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js')
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js
index a83ce8f..62b7b19 100644
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js
+++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/common/Storage.js
@@ -66,6 +66,13 @@ class ListStore {
});
}
+ static inlineItem(url) {
+ // here we simplify and hash inline script references
+ return url.startsWith("inline:") ? url
+ : url.startsWith("view-source:")
+ && url.replace(/^view-source:[\w-+]+:\/+([^/]+).*#line\d+/,"inline://$1#")
+ .replace(/\n[^]*/, s => s.replace(/\s+/g, ' ').substring(0, 16) + "…" + hash(s.trim()));
+ }
static hashItem(hash) {
return hash.startsWith("(") ? hash : `(${hash})`;
}
@@ -125,6 +132,14 @@ class ListStore {
return this.items.has(item);
}
}
+
+function hash(source){
+ var shaObj = new jssha("SHA-256","TEXT")
+ shaObj.update(source);
+ return shaObj.getHash("HEX");
+}
+
if (typeof module === "object") {
- module.exports = { ListStore, Storage };
+ module.exports = { ListStore, Storage, hash };
+ var jssha = require('jssha');
}