Canna.to | Make Javascript links to "normal" links
// ==UserScript==
// @name canna - expose links
// @include http://uu.canna.to/cpuser/links.php*
// @run-at document-start
// @grant none
// ==/UserScript==
document.addEventListener('DOMContentLoaded', function() {
var title = document.getElementById('fname');
if (title)
document.title = title.textContent;
[].forEach.call(document.querySelectorAll('tr[onclick*="location.href="]'), function(tr) {
var txt = document.evaluate(".//text()[normalize-space()!='']", tr, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (txt) {
tr.onclick = null;
var a = document.createElement('a');
a.href = tr.getAttribute('onclick').match(/location\.href='(.+?)'/)[1];
a.textContent = txt.textContent;
txt.parentNode.replaceChild(a, txt);
}
});
});
Great! That's exactly what I wanted.
Thank you very much!
Just a little side notice: the "@run-at" line breaks the script in my browser with GM.
Just a little side notice: the "@run-at" line breaks the script in my browser with GM.
I don't know why. It works here on FF39+GM3 and should work with any modern FF/GM.
I am using FF38.05 (PCX Custom Build) + GM3, but script works only if I delete this line. At least it works so I'm happy :-)
Canna.to | Make Javascript links to "normal" links
Hi Folks,
On http://uu.canna.to/cpuser/links.php (the User-Uploads site not the Main/Portal site) all links are made with Javascript (onclick). That makes it impossible to open links in new tabs.
Can somebody write a script to change the links, so you can open them in new tabs, please?
Thanks in advance!