rapidshare links checker

in Ideas and script requests
Subscribe to rapidshare links checker 9 posts, 4 voices



john34516 User

hello

i need rapidshare links checker for my forum(smf)

if one rapidshare link deleted to write under the post that is deleted

 
psyched Scriptwright


// ==UserScript==
// @name           Rapidshare Link Checker
// @namespace      http://userscripts.org/users/33515/scripts
// @description    Checks if rapidshare.com links have are invalid. If so, the links will be marked.
// @include        *
// ==/UserScript==


      var links = document.getElementsByTagName("a");
      for (var i=0; i<links.length; i++) {
        if (links[i].href.match(/^http:\/\/(www\.)?rapidshare\.com\/files\/\d+\/.+/gi)) {
          GM_xmlhttpRequest({
            method: "GET",
            url:    links[i].href,
            onload: function(e) {
              if (e.responseText.indexOf("File not found") > -1 || e.responseText.indexOf("This file has been deleted") > -1) {
                links[i].style.textDecoration = "line-through";
                links[i].title = "This link is invalid";
                //links[i].setAttribute("style", "text-decoration:line-through;");
                //links[i].setAttribute("title", "This link is invalid.");
              }
            }
          });
        }
      }

If the link is invalid, the link will look something like this:

I couldn't test it, since you didn't think so far as to post 2 links that have been deleted/are invalid, but I believe it will work.

And next time, try asking a little friendlier, a simple "please" would be nice ;)

 
sizzlemctwizzle Scriptwright

is it just me or should it be var links = document.getElementsByTagName("a");

 
psyched Scriptwright

Ah, Crap :D

Of course you're right :)

 
Descriptor Scriptwright

@sizzlemctwizzle
.getElementsByTagName("a") returns a list of all A elements, including anchors, and so will generate an error when it encounters an anchor that has no href property (though it may be that all A tags have a href property in the DOM). If you use document.links you get only links with an href. But you are right, there is no "links" tag so the script will fail (well I guess it took me 25 minutes to compile this). But then if you use xPath you can get an html collection that only contains rapidshare links, and so you could eliminate the regexp or have it do something more useful.

@john34516
I already made a script for this, which you would certainly find if you did a search, and you could comment in that script's section. It will not download the entire file (or even the error page) as would psyched's example in certain cases. I have heavily tested it and it works well, but with a couple problems yet - A large number of bad links (perhaps over 150, I'm not sure) will get your IP (apparently) blocked. I have figured out a fix for this. The script really only looks for good links, it isn't really designed to analyze bad links, I only need to know if a link is good.
Sometimes a server is down or isn't responding, this doesn't mean the file is gone, and I'm not sure if there's anything JavaScript can do about it since the timeout period is so long.
The script wouldn't post an edit to the forum, but I'm sure it could be patched to do so.
However, this is not the right way to do that, you'd be much better off with a server-side script to do the checking, it would be much faster and more reliable. I have talked to a forum moderator that uses one of these, and he was only using my script when for some reason the server-side script wasn't working.

 
psyched Scriptwright

Well, your script looks a little overkill to me.
As I said, I haven't tested my script, but I don't see why it shouldn't work.
If someone could maybe find broken rapidshare links I could figure out a way to improve it, be it speed or errors.

And why is your script so complicated? Is there a reason for that? I didn't look through your code, but it seems very, very overloaded to me.

 
Descriptor Scriptwright

You think that's complex, should see my local version.
Someone else wrote a script similar to yours, but that will download the entire page and if you don't have an account it eats your download bandwidth. Also there are more than a couple error messages and I don't even know what a paid member sees, which actually doesn't matter (I had a RS member test my script for me, so apparently it works).
My script is only complex because it tries to parse munged links and removes redirect URLs, it converts plain text links to hyperlinks and demunges those links as well. This is extremely hard to do and is never 100%. I based that on Linkify which also has several versions on us.o and had to modify it to add all the features listed in the description.

It's easy to find links, just do a Google search.

BTW: I know there are cases when I should be using switch, but I usually start out with one if and it sometimes breeds but I never go back and rewrite using switch, either because I'm not used to using it or I'm just lazy.

 
john34516 User

hello

how i can use that code on my site ?

please help me

 
Descriptor Scriptwright

Is it PHP? You can use one of these scripts but you need one that shows the Content-Type header, as the status code won't tell you anything. Maybe you can post that link to the smf guys, though they likely already know.
If you want to try my script just read the instructions.

You guys have at it, I'm getting a bit tired of "please help me" posters.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel