Advertisement
Guest User

TLBW Userscript for Opera faster load

a guest
Aug 24th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          TLBW
  3. // @description   Userscript to make teamliquid more useful for Brood War fans
  4. // @version       2.0
  5. // @include       http://teamliquid.net/
  6. // @include       http://teamliquid.net/index.php
  7. // @include       http://teamliquid.net/forum/*
  8. // @include       http://www.teamliquid.net/
  9. // @include       http://www.teamliquid.net/index.php
  10. // @include       http://www.teamliquid.net/forum/*
  11. // ==/UserScript==
  12.  
  13. /* Sections: news, general, sc2, bw, games, blogs, replays, calendar, streams, tlpd, liquipedia, tsl, poll */
  14.  
  15. var tlBW = function(){
  16.     function main() {
  17.         /* Move the Brood War forums above the SC2 forums */
  18.         move_section(bw, sc2);
  19.        
  20.         /* Move replays to above poll */
  21.         move_section(replays, poll);
  22.        
  23.         /* Remove poll */
  24.         //remove_section(poll);
  25.        
  26.         /* Move streams to above TSL */
  27.         move_section(streams, tsl);
  28.        
  29.         /* Change liquipedia search to Brood War liquipedia */
  30.         for (var i = 0; i < document.forms.length; i++) {
  31.             var form = document.forms[i];
  32.             if (form.action == "http://wiki.teamliquid.net/starcraft2/index.php")
  33.                 form.action = "http://wiki.teamliquid.net/starcraft/index.php";
  34.         }
  35.        
  36.         /* Change default tlpd search to BW (Korea) */
  37.         document.forms.namedItem('frm_tlpd_search').elements.namedItem("type").children[3].selected = true;
  38.        
  39.         /* Remove SC2 Elo rank display */
  40.         var rank1 = nextObject(document.forms.namedItem('frm_tlpd_search'));
  41.         var rank2 = nextObject(rank1);
  42.         rank1.parentNode.removeChild(rank1);
  43.         rank2.parentNode.removeChild(rank2);
  44.     }
  45.  
  46.     var nextObject = function(el) {
  47.         var n = el;
  48.         do n = n.nextSibling;
  49.         while (n && n.nodeType != 1);
  50.         return n;
  51.     }
  52.      
  53.     var previousObject = function(el) {
  54.         var p = el;
  55.         do p = p.previousSibling;
  56.         while (p && p.nodeType != 1);
  57.         return p;
  58.     }
  59.  
  60.     function Section(id, count, on_right) {
  61.         this.on_right = on_right;
  62.         this.elements = new Array();
  63.        
  64.         var link = document.getElementById(id);
  65.         this.elements.push(link);
  66.         for (var x = 0; x < count; x++) {
  67.             this.elements.push(nextObject(link));
  68.         }
  69.     }
  70.  
  71.     var news = new Section("nav_news_left_mid", 1, false);
  72.     var general = new Section("nav_general", 1, false);
  73.     var sc2 = new Section("nav_starcraft2", 1, false);
  74.     var bw = new Section("nav_broodwar", 1, false);
  75.     var games = new Section("nav_games", 1, false);
  76.     var blogs = new Section("nav_blogs", 1, false);
  77.     var replays = new Section("nav_replays", 1, false);
  78.  
  79.     var calendar = new Section("nav_calendar", 2, true);
  80.     var streams = new Section("nav_streams", 1, true);
  81.     var tlpd = new Section("nav_tlpd", 1, true);
  82.     var liquipedia = new Section("nav_wiki", 1, true);
  83.     var tsl = new Section("nav_tslforum", 1, true);
  84.     var poll = new Section("nav_poll", 1, true);
  85.  
  86.     var remove_section = function(section) {
  87.         for (var x = 0; x < section.elements.length; x++) {
  88.             var node = section.elements[x];
  89.             node.parentNode.removeChild(node);
  90.         }
  91.     }
  92.  
  93.     var prepend_section = function(section, location) {
  94.         var loc = location.elements[0];
  95.         for (var x = 0; x < section.elements.length; x++) {
  96.             var node = section.elements[x];
  97.             loc.parentNode.insertBefore(node, loc);
  98.         }
  99.     }
  100.  
  101.     var move_section = function(from, to) {
  102.         remove_section(from);
  103.         prepend_section(from, to);
  104.     }
  105.  
  106.     main();
  107.  
  108. }
  109. if (document.readyState==="loading") {
  110.     if (window.addEventListener) window.addEventListener("DOMContentLoaded",tlBW,false);
  111.     else if (window.attachEvent) window.attachEvent("onload",tlBW);
  112. } else if (document.readyState==="complete") {
  113.     tlBW();
  114. } else {
  115.     if (window.addEventListener) window.addEventListener("load",tlBW,false);
  116.     else if (window.attachEvent) window.attachEvent("onload",tlBW);
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement