Skip to content

Commit

Permalink
Use noopener tag and remove closures
Browse files Browse the repository at this point in the history
Add noopener tag to unwrapped google links since there is no
target=_blank. Move content script code out of anonymous self-executing
functions because they do not run in the global scope.
  • Loading branch information
bcyphers committed Jun 5, 2018
1 parent 6cf04d7 commit a0304e3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 1 addition & 3 deletions src/js/firstparties/google.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* globals findInAllFrames:false */
(function() {
let wrapped_link = "a[onmousedown^='return rwt(this,'], a[ping]";

// Remove excessive attributes and event listeners from link a
Expand All @@ -11,7 +10,7 @@ function cleanLink(a) {
a.removeAttribute(attr.name);
}
}
a.rel = "noreferrer";
a.rel = "noreferrer noopener";

// block event listeners on the link
a.addEventListener("click", function (e) { e.stopImmediatePropagation(); }, true);
Expand All @@ -23,4 +22,3 @@ function cleanLink(a) {
findInAllFrames(wrapped_link).forEach((link) => {
cleanLink(link);
});
}());
2 changes: 0 additions & 2 deletions src/js/firstparties/hangouts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* globals URL_REGEX:false */
(function() {
let hangouts_wrapped_link = "a[href^='https://www.google.com/url?']";

// Unwrap a Hangouts tracking link
Expand Down Expand Up @@ -29,4 +28,3 @@ function unwrapAll() {
}

setInterval(unwrapAll, 2000);
}());

0 comments on commit a0304e3

Please sign in to comment.