mirror of
https://github.com/wassname/RubberGlove.git
synced 2026-08-13 11:50:40 +08:00
Fix security issue that allowed recovery of the original navigator object.
This commit is contained in:
+11
-5
@@ -1,24 +1,28 @@
|
||||
//console.log("RubberGlove: Content Script for " + window.location.href);
|
||||
var compositeScript =
|
||||
"window.navigator = window.clientInformation = (" + bomOverloadFunction.toString() + "());\n"
|
||||
+ "(" + scriptCleanupFunction.toString() + "());";
|
||||
|
||||
// Create the script to be injected
|
||||
var pageScript = document.createElement('script');
|
||||
pageScript.type = 'text/javascript';
|
||||
pageScript.async = false;
|
||||
pageScript.text = compositeScript;
|
||||
pageScript.text = "(" + bomOverloadFunction.toString() + ")();"
|
||||
+ "(" + scriptCleanupFunction.toString() + ")();";
|
||||
|
||||
// Locate the <head> or create a new one if there isn't one or it isn't at
|
||||
// the top of the page.
|
||||
var html = document.documentElement
|
||||
var headTags = document.getElementsByTagName("head");
|
||||
var head = headTags.length > 0 ? head = headTags[0] : null;
|
||||
if(!head || head != html.firstChild) {
|
||||
if(!head || head !== html.firstChild) {
|
||||
head = document.createElement('head');
|
||||
html.insertBefore(head, html.firstChild);
|
||||
pageScript.id = "_RubberGlove_removeHead";
|
||||
}
|
||||
|
||||
// Listen for callbacks from the page script
|
||||
window.addEventListener("message", function(event) {
|
||||
if(event.source != window) return;
|
||||
if(event.data.type && event.data.type == "RubberGlove") {
|
||||
// Tell background.js to increment the badge counter
|
||||
chrome.runtime.sendMessage({
|
||||
type: "increment-counter",
|
||||
url: window.location.href,
|
||||
@@ -26,4 +30,6 @@ window.addEventListener("message", function(event) {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Insert our script into the page
|
||||
head.insertBefore(pageScript, head.firstChild);
|
||||
|
||||
Reference in New Issue
Block a user