Created
February 10, 2012 20:10
-
-
Save Orangenhain/1792384 to your computer and use it in GitHub Desktop.
Fix Safari links using Detox
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
If you use Safari and CMD+Click on a page to open it in a background tab, | |
the Safari History doesn't register the final URL, only the first step. | |
Leading to lots of links named "http://www.google.com/url?....12ASDF8234" | |
in your history, thus making it useless. | |
To fix this, one can change the Info.plist of Detox to also include the domains: | |
www.google.com, www.google.co.uk, www.google.XYZ, ... | |
( "www.google.*" apparently is an invalid pattern) | |
And add the following piece of code to end.js: |
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
else if (window.location.href.match(/www\.google\./)) | |
{ | |
// to get around Google's "Instant Search" feature | |
// ( i.e. this code would only get executed once, | |
// and does not see subsequent searches ), | |
// we use a timer | |
window.setInterval(function() | |
{ | |
var links = document.getElementsByClassName('l'); | |
for (var i=0, link; link = links[i++];) | |
{ | |
if ( ! link.onmousedown ) | |
{ | |
continue; | |
} | |
link.removeAttribute("onmousedown"); | |
console.log("link: " + link.href); | |
} | |
}, 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you change the
document.getElementsByClassName('l');
part to readdocument.querySelectorAll('a[onmousedown]');
, it will be a bit more robust (currently, the links don't have an 'l' class)