Advertisement
Guest User

Greasemonkey Script for CustomsForge.com search page

a guest
Sep 19th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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/-1
  8. // @include     https://search.customsforge.com/-1
  9. // @include     http://search.customsforge.com/#
  10. // @include     https://search.customsforge.com/#
  11. // @version     1
  12. // @grant       none
  13. // ==/UserScript==
  14.  
  15. function fixlinks () {
  16.  //console.log('customsforge userscript startup');
  17.  var dls=document.querySelectorAll("img.dl");
  18.  var infolink;
  19.  if(dls.length)
  20.   for(i=0;i<dls.length;i++ ) {
  21.    if(dls[i].parentNode.href.match(/r(\d+)$/)){
  22.     temphref=dls[i].parentNode.href;
  23.     infolink=document.createElement('a');
  24.     infolink.href=temphref;
  25.     dls[i].parentNode.href='http://customsforge.com/process.php?id='+dls[i].parentNode.href.match(/r(\d+)$/)[1];
  26.     dls[i].parentNode.parentNode.className='';
  27.     dls[i].parentNode.parentNode.title='Open download page for this track';
  28.     dls[i].parentNode.style.position='relative'
  29.     dls[i].parentNode.style.top='-9px';
  30.     dls[i].parentNode.style.right='-18px';
  31.     infolink.target="_blank";
  32.     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=" />';
  33.     infolink.className='cfinfolink';
  34.     infolink.title='More Info on this Track';
  35.     infolink.style.position='relative'
  36.     infolink.style.top='8px';
  37.     infolink.style.right='5px';
  38.     dls[i].parentNode.parentNode.insertBefore(infolink, dls[i].parentNode);
  39.     //console.log(dls[i].parentNode.href.match(/r(\d+)$/));
  40.    }
  41.   }
  42. }
  43.  
  44. function onNodeInserted() {
  45.   if(document.querySelector('.cfinfolink'))
  46.     return;
  47.   else
  48.     window.setTimeout(fixlinks,1000);
  49. }
  50.  
  51. window.setTimeout(fixlinks,1000);
  52. document.addEventListener('DOMNodeInserted', onNodeInserted, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement