Created
July 14, 2012 15:11
-
-
Save JossWhittle/3111758 to your computer and use it in GitHub Desktop.
Chrome Extension Script to convert all title links to open in new tabs. Requires jquery.
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
// JQuery included here... | |
// A variable to hold the "timeout-id" for our DOM check | |
var update; | |
// Page is ready | |
$(document).ready(function() { | |
// The DOM (page) was updated | |
$("body").bind("DOMSubtreeModified", function() { | |
// Attempt to clear the currently scheduled check | |
try { clearTimeout(update); } catch(err) {} | |
// Schedule a new check for 100ms time from now | |
update = setTimeout(function() { | |
fix(); | |
}, 100); | |
}); | |
}); | |
// Any DOM optimizations we want to do go here | |
function fix() { | |
// Make sure all <a> for post titles are set to | |
// open in a new tab (target="_blank") | |
$('a.title').attr('target', '_blank'); | |
// I decided I wanted the comment link in a new tab too... | |
$('a.comments').attr('target', '_blank'); | |
} |
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
{ | |
"name": "Reddit Linker", | |
"version": "0.1", | |
"description": "Makes Reddit title links open in a new tab...", | |
"permissions": [ | |
"tabs", "http://www.reddit.com/*" | |
], | |
"content_scripts": [{ | |
"matches": ["http://www.reddit.com/*"], | |
"js": ["linker.js"] | |
}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment