delete global WEB_API_MANAGER_PAGE property from page DOM once we're done with it, which should be the last remnant of the extension in the page script.

This commit is contained in:
Peter Snyder 2017-10-17 15:00:52 -05:00
parent 4f384d6476
commit 0d6e941dd1
2 changed files with 9 additions and 2 deletions

View file

@ -31,4 +31,4 @@
script.appendChild(doc.createTextNode(code));
rootElm.appendChild(script);
}());
}());

View file

@ -157,9 +157,16 @@
featuresToBlock.forEach(blockFeatureAtKeyPath);
// Next, delete the WEB_API_MANAGER_PAGE global property. Technically
// this never needed to be global, but doing so allows for easier
// jslinting of the code, makes things easier to understand (for me
// at least) and doesn't have any side effect as long as we delete
// it when we're done, and before the page scripts can start running.
delete window.WEB_API_MANAGER_PAGE;
// Last, remove the script tag containing this code from the document,
// so that the structure of the page looks like what the page author
// expects / intended.
const scriptTags = getElementsByTagName.call(window.document, "script");
removeChild.call(scriptTags[0].parentNode, scriptTags[0]);
}());
}());