Created
October 19, 2014 15:59
-
-
Save deeeki/530eaaa16ea30840b883 to your computer and use it in GitHub Desktop.
Digg Reader open in background tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Digg Reader open in background tab | |
// @namespace http://deeeki.com/ | |
// @include https://digg.com/reader/* | |
// @version 0.1.0 | |
// @description A port of "LDR open in background tab" for Digg Reader | |
// ==/UserScript== | |
(function(window, load) { | |
if (this.chrome && !load) { | |
var fn = '(' + arguments.callee.toString() + ')(this, true);'; | |
var script = document.createElement('script'); | |
script.appendChild(document.createTextNode(fn)); | |
document.body.appendChild(script); | |
return; | |
} | |
var native_open = window.native_open = window.open; | |
window.open = function(url,name) { | |
if (url === void 0) return native_open(url,name); | |
var a = document.createElement('a'); | |
a.href = url; | |
if (name) a.target = name; | |
var event = document.createEvent('MouseEvents'); | |
event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 1, null); | |
a.dispatchEvent(event); | |
return true; | |
} | |
})(this.unsafeWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment