aboutsummaryrefslogtreecommitdiff
path: root/bg
diff options
context:
space:
mode:
authorStef Gijsberts <stef@stef.link>2021-11-03 19:42:10 +0100
committerYuchen Pei <hi@ypei.me>2021-11-10 14:39:32 +1100
commita3c44b07a5f587311926fedf017e110cfa5d9255 (patch)
tree75cf2f8475b7fd53d0e3de25f0e2b9ab85f9aa66 /bg
parent0f6fbdaa4dd0aed4e830da244f7bf1b6ceaaaf26 (diff)
Rename variable `document` to `doc`
This is done because shadowing the global variable `document` can lead to unexpected results.
Diffstat (limited to 'bg')
-rw-r--r--bg/ExternalLicenses.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/bg/ExternalLicenses.js b/bg/ExternalLicenses.js
index 33bcbf6..d5bcd4e 100644
--- a/bg/ExternalLicenses.js
+++ b/bg/ExternalLicenses.js
@@ -103,7 +103,7 @@ var ExternalLicenses = {
* modify the rendered HTML but rather feed the content script on demand.
* Returns true if the document has been actually modified, false otherwise.
*/
- optimizeDocument(document, cachePointer) {
+ optimizeDocument(doc, cachePointer) {
let cache = {};
let {tabId, frameId, documentUrl} = cachePointer;
let frameCache = cachedHrefs.get(tabId);
@@ -112,12 +112,12 @@ var ExternalLicenses = {
}
frameCache.set(frameId, new Map([[documentUrl, cache]]));
- let link = document.querySelector(`link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]`);
+ let link = doc.querySelector(`link[rel="jslicense"], link[data-jslicense="1"], a[rel="jslicense"], a[data-jslicense="1"]`);
if (link) {
let href = link.getAttribute("href");
cache.webLabels = {href};
- let move = () => !!document.head.insertBefore(link, document.head.firstChild);
- if (link.parentNode === document.head) {
+ let move = () => !!doc.head.insertBefore(link, doc.head.firstChild);
+ if (link.parentNode === doc.head) {
for (let node; node = link.previousElementSibling;) {
if (node.tagName.toUpperCase() === "SCRIPT") {
return move();
@@ -125,7 +125,7 @@ var ExternalLicenses = {
}
} else { // the reference is only in the body
if (link.tagName.toUpperCase() === "A") {
- let newLink = document.createElement("link");
+ let newLink = doc.createElement("link");
newLink.rel = "jslicense";
newLink.setAttribute("href", href);
link = newLink;