mirror of
				https://github.com/arkenfox/user.js.git
				synced 2025-11-04 07:45:26 +01:00 
			
		
		
		
	Updated 4.2.1 User Scripts (markdown)
@@ -32,51 +32,3 @@ if (window.opener !== null) {
 | 
				
			|||||||
  console.warn('Cleared window.opener @ ' + document.location.toString());
 | 
					  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);
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user