SHOW:
|
|
- or go back to the newest paste.
| 1 | // ==UserScript== | |
| 2 | // @name Fix Customs Forge Search Page's Download links | |
| 3 | // @namespace CustomsForge | |
| 4 | // @description Fixes the download links on the CustomsForge.com search page | |
| 5 | // @include http://search.customsforge.com/ | |
| 6 | // @include https://search.customsforge.com/ | |
| 7 | // @include http://search.customsforge.com/* | |
| 8 | // @include https://search.customsforge.com/* | |
| 9 | - | // @version 2 |
| 9 | + | // @version 3 |
| 10 | // @grant none | |
| 11 | // ==/UserScript== | |
| 12 | ||
| 13 | function fixlinks () {
| |
| 14 | //console.log('customsforge userscript startup');
| |
| 15 | - | var dls=document.querySelectorAll("img.dl");
|
| 15 | + | |
| 16 | - | var infolink; |
| 16 | + | var trs=document.querySelectorAll('#songs_table tr.odd,#songs_table tr.even');
|
| 17 | - | if(dls.length) |
| 17 | + | var songtd; |
| 18 | - | for(i=0;i<dls.length;i++ ) {
|
| 18 | + | qlink=document.createElement('a');
|
| 19 | - | if(dls[i].parentNode.href.match(/r(\d+)$/)){
|
| 19 | + | qlink.innerHTML=' <b>?</b>'; |
| 20 | - | temphref=dls[i].parentNode.href; |
| 20 | + | for(i=0;i<trs.length;i++) {
|
| 21 | - | infolink=document.createElement('a');
|
| 21 | + | songtd=trs[i].getElementsByTagName('td')[2];
|
| 22 | - | infolink.href=temphref; |
| 22 | + | console.log(songtd.textContent); |
| 23 | - | dls[i].parentNode.href='http://customsforge.com/process.php?id='+dls[i].parentNode.href.match(/r(\d+)$/)[1]; |
| 23 | + | dllink=trs[i].querySelector('img.dl').parentNode.href;
|
| 24 | - | dls[i].parentNode.parentNode.className=''; |
| 24 | + | if(dllink.match(/r(\d+)$/)){
|
| 25 | - | dls[i].parentNode.parentNode.style='display:table'; |
| 25 | + | qlink.href=songtd.getElementsByTagName('a')[0].href;
|
| 26 | - | dls[i].parentNode.parentNode.title='Open download page for this track'; |
| 26 | + | qlink.title='Check for more versions of this song'; |
| 27 | - | dls[i].parentNode.style.display='table-cell'; |
| 27 | + | songtd.appendChild(qlink.cloneNode(true)); |
| 28 | - | dls[i].parentNode.style.paddingLeft='4px'; |
| 28 | + | songtd.getElementsByTagName('a')[0].href=dllink;
|
| 29 | - | infolink.target="_blank"; |
| 29 | + | songtd.getElementsByTagName('a')[0].title='Song Info';
|
| 30 | - | infolink.innerHTML='<img width="16" height="16" alt="info" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAAXNSR0IArs4c6QAAAIpQTFRFAAAAMzMzNjY2ODg4OTk5Pj4+QEBARERERUVFRkZGSUlJS0tLTU1NUFBQUVFRWVlZWlpaW1tbbGxsbW1tbm5ub29vdXV1eXp5enp6e3t7fn9+gYGBhYWFlpaWnZ6epKSkpqamqKiorq+utLW1uLi4v8DAxcXFxsbFyMnIzc/N0dLR4OHg4eHh5eXlr9AYygAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3AUZDAkDDQjyBgAAAItJREFUGNNdj9cWwjAMQ6VC2FBG2JQyQlnl/3+PRnV5wC86uZZsB4gVPJ0PaCqQHE4HpKGsereeKCrJmj47wNux9lC1Pa+lZuhP0tVIIMBHmT/wWQp4xCSTE8q2gKsBL7jRgCLJCwdaREMXQJc2VGuPuM/2tlaWK8piYwadngM7NqdHTy8d//r/3/8CNq4H/103LSAAAAAASUVORK5CYII=" />'; |
| 30 | + | trs[i].querySelector('img.dl').parentNode.href='http://customsforge.com/process.php?id='+dllink.match(/r(\d+)$/)[1];
|
| 31 | - | infolink.className='cfinfolink'; |
| 31 | + | trs[i].querySelector('img.dl').parentNode.title="Download Page";
|
| 32 | - | infolink.title='More Info on this Track'; |
| 32 | + | } |
| 33 | - | infolink.style.display='table-cell'; |
| 33 | + | |
| 34 | - | dls[i].parentNode.parentNode.insertBefore(infolink, dls[i].parentNode); |
| 34 | + | |
| 35 | - | } |
| 35 | + | |
| 36 | ||
| 37 | function onNodeInserted() {
| |
| 38 | if(document.querySelector('.cfinfolink'))
| |
| 39 | return; | |
| 40 | else | |
| 41 | window.setTimeout(fixlinks,1000); | |
| 42 | } | |
| 43 | ||
| 44 | window.setTimeout(fixlinks,1000); | |
| 45 | document.addEventListener('DOMNodeInserted', onNodeInserted, false); |