Source for "Gigeshare download timer remover"

By laughingLoki
Has 6 other scripts.


// ==UserScript==
// @name          Gigeshare download timer remover
// @namespace     http://gigeshare.com
// @description   (v1.10)  Removes the download timer on gigeshare.com and gives you a clean page with download links
// @include       http://*.gigeshare.com/file/*
// @include       http://*.gigeshare.com/preview/*
// @include       http://gigeshare.com/file/*
// @include       http://gigeshare.com/preview/*
// ==/UserScript==

/*******************************************************************************
functions to edit the page:
*******************************************************************************/

function hide(id)
{
    if(document.getElementById(id))
        document.getElementById(id).style.display="none";
}

function show(id)
{
    if(document.getElementById(id))
        document.getElementById(id).style.display="";
}


function replace(id, val)
{
    if(document.getElementById(id))
        document.getElementById(id).innerHTML=val;
}

function append(id, val)
{
    if(document.getElementById(id))
        document.getElementById(id).innerHTML+=val;
}

function prepend(id, val)
{
    if(document.getElementById(id))
    {
        element=document.getElementById(id);
        element.innerHTML=val+element.innerHTML;
    }
}

function hard_refresh()
{
    window.location.href=window.location.href;
}

function replace_body(content)
{
    document.getElementsByTagName("body")[0].innerHTML=content;
}

function append_body(content)
{
    document.getElementsByTagName("body")[0].innerHTML+=content;
}

function prepend_body(content)
{
    body=document.getElementsByTagName("body")[0];
    body.innerHTML=content+body.innerHTML;
}


function replace_head(content)
{
    document.getElementsByTagName("head")[0].innerHTML=content;
}

function append_head(content)
{
    document.getElementsByTagName("head")[0].innerHTML+=content;
}

function prepend_head(content)
{
    head=document.getElementsByTagName("head")[0];
    head.innerHTML=content+head.innerHTML;
}

function search_page(tag, content)
{
    element=document.getElementsByTagName(tag);
    for(i=0; i<element.length; i++)
    {
        contents=element[i].innerHTML;
        if(contents.search(content)>=0)
            return true;
    }
    
    return false;
}


function getElementsByClassName(class)
{
    arr=new Array();
    i=0;

    element=document.getElementsByTagName("*");
    for(i=0; i<element.length; i++)
    {
        if(element.class==class)
        {  
            arr[i]=element;
            i++;
        }
    }
    
    return arr;
}


/*******************************************************************************
script follows:
*******************************************************************************/

// get links
a = document.getElementsByTagName("a");

link=new Array();
j=0; // current index of link array

// iterate through all links
for(i=0; i<a.length; i++)
{
    // find continuation link and go to it
    if(a[i].href.search("file")>=0 || a[i].innerHTML=="Continuation Link")
    {
        window.location.href=a[i].href;
    }
        
    // find download links and store them
    if(a[i].href.search("download")>=0)
    {
        link[j]=a[i].href;
        j++;
    }
}

newBody="";

// set up part of new page text
newBody+="<div>Here are your links, good sir:<br />";

// iterate through all download links
for(i=0; i<link.length; i++)
{ 
    newBody+="<a href=\""+link[i]+"\">"+link[i]+"</a><br />";
}

if(link.length==0)
    newBody+="<br /><br />It looks like there's no links here.  I'll bet some cheeky nutter reported the files.  Please disable Greasemonkey and reload the page just to be sure the file is indeed gone.";

// end new page text
newBody+="</div>";


// overwrite the HTML with just the links
replace_head("");
replace_body(newBody);