Advertisement
Guest User

Greasemonkey Script to improve CustomsForge.com search page

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