Advertisement
cyla

PH! relative links

Jun 5th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name            PH! relative links
  3. // @author          arfhelf, cyla
  4. // @version         0.2.1
  5. // @namespace       archelf.ph
  6. // @description     Create relative links from absolute links
  7. // @include         http://prohardver.hu/*
  8. // @include         http://itcafe.hu/*
  9. // @include         http://mobilarena.hu/*
  10. // @include         http://gamepod.hu/*
  11. // @include         http://logout.hu/*
  12. // ==/UserScript==
  13.  
  14. /*
  15. Versions:
  16. 0.1a                Initial release
  17. 0.2                 Initial opera release
  18.                     Added includes instead of URLCheck
  19.                     Replace forum links only
  20.                     Replace links with www subdomains
  21.                     Replace rios4 forum links
  22.                     Replace rios3 forum links with rios4 ones
  23. 0.2.1               Replace user links
  24. */
  25.  
  26. (function(){
  27.     var center = document.getElementById( "center" );
  28.     var anchors = center.getElementsByTagName( "a" );
  29.  
  30.     for ( var x = 0; x < anchors.length; x++ ) {
  31.         var url = anchors[x].href;
  32.         anchors[x].href = URLTrim( url );
  33.     }
  34. })();
  35.  
  36. function URLTrim( url ) {
  37.     var sites = Array(
  38.         "http://prohardver.hu/",
  39.         "http://www.prohardver.hu/",
  40.         "http://itcafe.hu/",
  41.         "http://www.itcafe.hu/",
  42.         "http://logout.hu/",
  43.         "http://www.logout.hu/",
  44.         "http://mobilarena.hu/",
  45.         "http://www.mobilarena.hu/",
  46.         "http://gamepod.hu/",
  47.         "http://www.gamepod.hu/"
  48.     );
  49.  
  50.     for ( var x = 0; x < sites.length; x++ ) {
  51.         if ( ( url.indexOf( sites[x] ) == 0 ) && ( url.length > sites[x].length ) && ( ( url.search( ".hu/tema/" ) != -1 ) || ( url.search( ".hu/tag/" ) != -1 ) || ( url.search( ".hu/f.php" ) != -1 ) || ( url.search( ".hu/rios3_forum.php" ) != -1 ) ) ) {
  52.             url = url.substring( sites[x].length - 1 );
  53.  
  54.             if ( url.search( "rios3" ) != -1 ) {
  55.                 var re = /(.*\/)rios3_forum\.php\?mod=(\d+)\&id=(\d+).*/;
  56.                 url = url.replace( re, "$1f.php?mod=$2&id=$3" );
  57.             }
  58.         }
  59.     }
  60.  
  61.     return url;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement