Skip to content

Instantly share code, notes, and snippets.

@deeeki
Created October 19, 2014 15:59
Show Gist options
  • Save deeeki/530eaaa16ea30840b883 to your computer and use it in GitHub Desktop.
Save deeeki/530eaaa16ea30840b883 to your computer and use it in GitHub Desktop.
Digg Reader open in background tab
// ==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