Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Fix Customs Forge Search Page's Download links
- // @namespace CustomsForge
- // @description Fixes the download links on the CustomsForge.com search page
- // @include http://search.customsforge.com/
- // @include https://search.customsforge.com/
- // @include http://search.customsforge.com/*
- // @include https://search.customsforge.com/*
- // @version 3.2
- // @grant none
- // ==/UserScript==
- function fixlinks () {
- var trs=document.querySelectorAll('#songs_table tr.odd,#songs_table tr.even');
- var songtd;
- qlink=document.createElement('a');
- // bigger search "button"
- qlink.innerHTML='<b>[ S ]</b>';
- for(i=0;i<trs.length;i++) {
- songtd=trs[i].getElementsByTagName('td')[2];
- dllink=trs[i].querySelector('img.dl').parentNode.href;
- if(dllink.match(/r(\d+)$/)){
- qlink.href=songtd.getElementsByTagName('a')[0].href;
- qlink.title='Check for more versions of this song';
- songtd.appendChild(qlink.cloneNode(true));
- songtd.getElementsByTagName('a')[0].href=dllink;
- songtd.getElementsByTagName('a')[0].title='Song Info';
- // send new link to right
- songtd.getElementsByTagName('a')[1].setAttribute("style", "float:right;");
- trs[i].querySelector('img.dl').parentNode.href='http://customsforge.com/process.php?id='+dllink.match(/r(\d+)$/)[1];
- trs[i].querySelector('img.dl').parentNode.title="Download Page";
- // send play button to right
- var ytButton = songtd.firstChild;
- if (typeof ytButton !== "undefined") {
- if ((ytButton.tagName == 'DIV') && (ytButton.id.substr(0, 3) == "yt_") ) {
- parent = ytButton.parentNode,
- prev = ytButton.previousSibling,
- oldChild = parent.removeChild(ytButton);
- oldChild.setAttribute('style', 'float:right;');
- parent.insertBefore( oldChild, prev );
- }
- }
- }
- else {
- // for official dlc
- var ytButton = songtd.firstChild;
- if (typeof ytButton !== "undefined") {
- if ((ytButton.tagName == 'DIV') && (ytButton.id.substr(0, 3) == "yt_") ) {
- parent = ytButton.parentNode,
- prev = ytButton.previousSibling,
- oldChild = parent.removeChild(ytButton);
- oldChild.setAttribute('style', 'float:right;padding-right: 24px;');
- parent.insertBefore( oldChild, prev );
- }
- }
- }
- }
- }
- function onNodeInserted() {
- if(document.querySelector('.cfinfolink')) {
- return;
- }
- else {
- window.setTimeout(fixlinks,1000);
- }
- }
- window.setTimeout(fixlinks,1000);
- document.addEventListener('DOMNodeInserted', onNodeInserted, false);
Add Comment
Please, Sign In to add comment