Created
March 16, 2012 13:20
-
-
Save btleffler/2050040 to your computer and use it in GitHub Desktop.
Basecamp Links Open in New Window/Tap
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
/* | |
* Go through all the links in Basecamp comments | |
* and make them open in a new window | |
* | |
* Author: Benjamin Leffler <[email protected]> | |
* Date: 03/16/12 | |
*/ | |
// ==UserScript== | |
// @match https://*.basecamphq.com/* | |
// ==/UserScript== | |
( function () { | |
"use strict"; | |
// Get the div.formatted_text_body tags | |
var divs = document.getElementsByClassName( "formatted_text_body" ), | |
dLen = divs.length, | |
i, aTags, j, aLen; | |
for ( i = 0; i < dLen; i++ ) { | |
// Probably safer to get the anchor tags this way, | |
// since a nodeList is not guaranteed | |
aTags = divs[ i ].getElementsByTagName( "a" ); | |
aLen = aTags.length; | |
// Go through each anchor tag and set their target to "_blank" | |
for ( j = 0; j < aLen; j++ ) { | |
aTags[ j ].setAttribute( "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
// ==UserScript== | |
// @match https://*.basecamphq.com/* | |
// ==/UserScript== | |
(function(){"use strict";var a=document.getElementsByClassName("formatted_text_body"),b=a.length,c,d,e,f;for(c=0;c<b;c++){d=a[c].getElementsByTagName("a");f=d.length;for(e=0;e<f;e++){d[e].setAttribute("target","_blank");}}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basecamp Link Fix
Makes all the links in Basecamp comments open in a new window or tab!
To install, click
raw
onbasecamp-link-fix.user.js
and your browser should do the rest.