From 8c16a81f05d2fc759d9355885da4ebac4397b3a9 Mon Sep 17 00:00:00 2001 From: earthlng Date: Wed, 12 Feb 2020 10:31:08 +0000 Subject: [PATCH] Updated 4.2.1 User Scripts (markdown) --- 4.2.1-User-Scripts.md | 48 ------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/4.2.1-User-Scripts.md b/4.2.1-User-Scripts.md index 992079d..fa60810 100644 --- a/4.2.1-User-Scripts.md +++ b/4.2.1-User-Scripts.md @@ -32,51 +32,3 @@ if (window.opener !== null) { console.warn('Cleared window.opener @ ' + document.location.toString()); } ``` - ---- - -### :small_orange_diamond: Conceal window.name - - * Author: [earthlng](https://github.com/earthlng) - * Description: See [bugzilla 444222](https://bugzilla.mozilla.org/show_bug.cgi?id=444222) - * Test: [JonDonym](http://ip-check.info/?lang=en) - * Note: you need to add `http://ip-check.info/?lang=en` as an exception. This is the landing page with the "Test" link on it. - -```js -// ==UserScript== -// @name Conceal window.name -// @version 2.0 -// @match http://*/* -// @match https://*/* -// @exclude /^https://www\.google\.com/recaptcha/api2/(?:anchor|frame)\?.+$/ -// @run-at document-start -// @namespace ghacksuserjs -// @grant GM.notification -// ==/UserScript== - -const windowNames = new WeakMap(); - -const unsafeWindow = window.wrappedJSObject; -const descriptor = Object.getOwnPropertyDescriptor(unsafeWindow, 'name'); -const originalget = descriptor.get; -const originalset = descriptor.set; -const fakeobj = { - get name() { - const originalName = originalget.apply(this); - const returnedName = windowNames.get(window) || ''; - if (originalName !== returnedName) - GM.notification('Intercepted read access to window.name "'+originalName+'" from '+window.location); - return returnedName; - }, - set name(newname) { - originalset.apply(this, window.Array.from(arguments)); - windowNames.set(window, newname); - } -}; - -descriptor.get = exportFunction(Object.getOwnPropertyDescriptor(fakeobj, 'name').get, window); -descriptor.set = exportFunction(Object.getOwnPropertyDescriptor(fakeobj, 'name').set, window); - -Reflect.defineProperty(unsafeWindow, 'name', descriptor); -``` -