Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////
  2. //   CMod   //
  3. //////////////
  4.  
  5. var userID;
  6. var ky;
  7.  
  8. $(document).ready(
  9.     function(){
  10.         var start = performance.now();
  11.  
  12.         userID = proboards.data("user").id;
  13.         GetUserKey();
  14.        
  15.         //Changing links to the board
  16.         $("#logo").prop("href", "http://genericdiscussion.freeforums.net/board/1/general-board");
  17.         document.getElementById("navigation-menu").childNodes[1].childNodes[1].childNodes[1].href = "http://genericdiscussion.freeforums.net/board/1/general-board";
  18.         EnabledSettings();
  19.        
  20.         //Adding events upon load and page changing
  21.         try {
  22.             colonelGift();
  23.             setTimeout(function() {
  24.                 var start = performance.now();
  25.                 colonelGift();
  26.                 PlayerUnfuck();
  27.                 TwitchHandling();
  28.                 //if(ky.holiday && ky.enabled) Hattify();
  29.                 var end = performance.now();
  30.                 var time = end - start;
  31.                 console.log('CMod delayed function execution time: ' + Math.round(time * 100) / 100 + " miliseconds");
  32.                 setInterval(function(){
  33.                    
  34.                     PlayerUnfuck();
  35.                     var start = performance.now();
  36.                     TwitchHandling();
  37.                     colonelGift();
  38.                     var end = performance.now();
  39.                     var time = end - start;
  40.                     console.log('CMod interval function execution time: ' + Math.round(time * 100) / 100 + " miliseconds");
  41.                 }, 2000);
  42.             }, 1500);
  43.             var pageButtons = document.querySelectorAll(".ui-pagination li");
  44.             for (i = 0; i < pageButtons.length; ++i) {
  45.                 pageButtons[i].childNodes[0].addEventListener("click", function() {
  46.                     $("html, body").animate({ scrollTop: $("#navigation-menu").offset().top }, 500)
  47.                     setTimeout(function() {
  48.                         PlayerUnfuck();
  49.                         var start = performance.now();
  50.                         TwitchHandling();
  51.                         BlockThreadClass();
  52.                         if(ky.blank && ky.enabled) stopBlankFuckers();
  53.                         if(ky.username && ky.enabled) DisplayUsernames();
  54.                         //if(ky.holiday && ky.enabled) Hattify();
  55.                         var end = performance.now();
  56.                         var time = end - start;
  57.                         console.log('CMod onclick delayed execution time: ' + Math.round(time * 100) / 100 + " miliseconds");
  58.                     }, 1500);
  59.                 });
  60.             }
  61.             BlockThreadClass()
  62.         }catch(err){console.log(err);}
  63.        
  64.         if(ky.enabled == 0){return;}
  65.         //Adding panel HTML
  66.         var htmlinsert = '<div id="cmod-wrapper"> <h1>CMod</h1> <div id="cmod-post-height-wrapper"><span id="cmod-post-height-label">Post height limit in pixels (0=no limit): </span> <input id="cmod-post-limit" type="number" value="0" min="0" max="4000" maxlength="4"> </div><div id="cmod-sig-height-wrapper"><span id="cmod-sig-height-label">Signature height limit in pixels (0=no limit): </span> <input id="cmod-sig-limit" type="number" value="0" min="0" max="1000" maxlength="4" size="4"> </div><div id="cmod-bpost-wrapper"><span id="cmod-bpost-label">Blocked post handling:</span> </br> <div style="text-align: left;"> <input type="radio" name="cmod-bpost" id="cmod-bpost-0" value="0" checked> Default </br> <input type="radio" name="cmod-bpost" id="cmod-bpost-1" value="1"> Thin line </br> <input type="radio" name="cmod-bpost" id="cmod-bpost-2" value="2"> Thin line - click to reveal </br> <input type="radio" name="cmod-bpost" id="cmod-bpost-3" value="3"> Completely hide </br> </div></div><div id="cmod-bthread-wrapper"><span id="cmod-bthread-label">Blocked thread handling:</span> </br> <div style="text-align: left"> <input type="radio" name="cmod-bthread" id="cmod-bthread-0" value="0" checked> Default </br> <input type="radio" name="cmod-bthread" id="cmod-bthread-1" value="1"> Thin line </br> <input type="radio" name="cmod-bthread" id="cmod-bthread-2" value="2"> Completely hide </br> </div></br><a target="_blank" href="http://genericdiscussion.freeforums.net/thread/54455/">If you\'re having issues with thread blocking, this might help</a></div><div id="cmod-color-wrapper">Blocked line color: <input type="color" id="cmod-color" value="#8B0000"> </div><div id="cmod-username-wrapper" style="text-align: left;"> <input id="cmod-username" type="checkbox" value="0" min="0" max="4000" maxlength="4"><span id="cmod-username-label">Show usernames under display names </span> </div><div id="cmod-blank-wrapper" style="text-align: left;"> <input id="cmod-blank" type="checkbox" value="0" min="0" max="4000" maxlength="4"><span id="cmod-username-label">Replace blank names with usernames </span> </div><div id="cmod-holiday-wrapper" style="text-align: left;"><span id="cmod-holiday-label">Are you triggered by holiday stuff or use a toaster?</span></br> <div><input id="cmod-holiday" type="checkbox" value="0" min="0" max="4000" maxlength="4"><span id="cmod-username-label">Show Holiday Stuff?</span></div></div><div id="cmod-twitch-wrapper"><span id="cmod-twitch-label">Twitch handling:</span> </br> <div style="text-align: left;"> <input type="radio" name="cmod-twitch" id="cmod-twitch-0" value="0"> Keep embeds and autoplay </br> <input type="radio" name="cmod-twitch" id="cmod-twitch-1" value="1" checked> Keep embeds but turn off autoplay</br> <input type="radio" name="cmod-twitch" id="cmod-twitch-2" value="2"> Turn Twitch embeds into links </br> </div></div><div style="clear: both;"></div></br> <input type="button" id="cmod-close" value="Close" class="cmodbutton" onclick="PanelToggle()"> <input type="button" id="cmod-save" value="Save" class="cmodbutton" onclick="Save();"> <input type="button" class="cmodbutton" id="cmod-reset" value="Reset" onclick="LoadKey()"> <div style="clear: both;"></div><div style="text-align: center;"> </br><a target="_blank" href="http://i.subarashii.me/93f43">Like, Favorite and Subscribe for more forum ruining</a></br> </br> </br> </div></div>';
  67.         document.querySelector("#banner-container").innerHTML+=htmlinsert;
  68.        
  69.         //Adding panel CSS
  70.         var css_popup = "#cmod-bpost-wrapper,#cmod-bthread-wrapper,#cmod-color-wrapper,#cmod-blank-wrapper,#cmod-holiday-label,#cmod-holiday-wrapper,#cmod-post-height-wrapper,#cmod-sig-height-wrapper,#cmod-twitch-wrapper,#cmod-username-wrapper,h1{margin-bottom:15px}h1{font-size:30px}#cmod-wrapper{z-index:2000;position:fixed;display:none;bottom:0;left:0;box-sizing:border-box;width:500px;height:750px;padding-top:30px;padding-left:30px;padding-right:30px;border-top:2px solid #000;border-right:2px solid #000;background-color:#575757;color:#fff;text-align:center;overflow-y:auto}#cmod-post-limit,#cmod-sig-limit{width:50px}.cmodbutton{color:#fff!important;float:right;margin-left:10px;width:55px;height:25px;background-color:#575757!important;border-color:#fff!important;background-image:none!important}.cmodbutton:hover{color:#fff!important;background-color:#5F5F5F!important}.cmodbutton:active{color:#fff!important;background-color:#1D1D1D!important}#cmod-color{width:120px}a{color:#add8e6}";
  71.         var css_style = document.createElement("style");
  72.         css_style.appendChild(document.createTextNode(css_popup));
  73.         document.querySelector("head").appendChild(css_style);
  74.        
  75.         //disabling save button if user logged out
  76.         if(userID == 0){
  77.             document.getElementById('cmod-save').disabled = true;
  78.             document.getElementById('cmod-save').style.visibility = "hidden";          
  79.         }
  80.        
  81.         //Adding CMod Panel toggle button
  82.         var navbar = document.querySelector("ul[role=navigation]");
  83.         var navbarItem = document.createElement('li');
  84.         var panelButton = document.createElement('a');
  85.         panelButton.appendChild(document.createTextNode("Show CMod Panel"));
  86.         panelButton.setAttribute("id", "panelButton");
  87.         panelButton.setAttribute("onclick", "PanelToggle()");
  88.         navbarItem.appendChild(panelButton);
  89.         navbar.appendChild(navbarItem);
  90.        
  91.         LoadKey();
  92.  
  93.         //Applying the CSS options
  94.         var css_insert = "";
  95.         if (ky.plimit > 0) css_insert += "article .message, .content .message{padding-right:5px; overflow-y: auto !important; max-height:" + ky.plimit + "px;}";
  96.         if (ky.slimit > 0) css_insert += ".signature{overflow-y: auto; max-height: " + ky.slimit + "px;}";
  97.         switch (ky.bpost) {
  98.             case 0:
  99.                 break;
  100.             case 1:
  101.                 css_insert += ".blocked a, .blocked a:hover, .blocked a:active{display: none;}.blocked .message{display: none !important;}.blocked{padding: 0px !important; height: 10px; font-size: 1px; background-color:" + ky.clr + ";}";
  102.                 break;
  103.             case 2:
  104.                 css_insert += ".blocked a, .blocked a:hover, .blocked a:active{font-size: 0px !important; width: 100%; height: 10px !important; min-height: 10px !important; box-sizing: border-box; border-top-left-radius: 0px;border-top-right-radius: 0px; border-radius: 0px 0px 0px 0px; background-image: none !important; margin: 0px !important; padding: 0px !important; background-color:" + ky.clr + "!important;}.blocked .message{display: none !important;}.blocked{padding: 0px !important; height: 10px; font-size: 1px; background-color:" + ky.clr + ";}";
  105.                 break;
  106.             case 3:
  107.                 css_insert += ".blocked{display: none !important;}";
  108.                 break;
  109.         }
  110.         switch (ky.bthread) {
  111.             case 0:
  112.                 break;
  113.             case 1:
  114.                 css_insert += ".blocked-thread{font-size: 0px !important; width: 100%; height: 10px !important; min-height: 10px !important; box-sizing: border-box; border-top-left-radius: 0px;border-top-right-radius: 0px; border-radius: 0px 0px 0px 0px; background-image: none !important; margin: 0px !important; padding: 0px !important; background-color:" + ky.clr + "!important;}";
  115.                 break;
  116.             case 2:
  117.                 css_insert += ".blocked-thread{display: none;}";
  118.                 break;
  119.         }
  120.         css_insert += "";
  121.         var css_options_style = document.createElement("style");
  122.         css_options_style.appendChild(document.createTextNode(css_insert));
  123.         document.querySelector("head").appendChild(css_options_style);        
  124.        
  125.         if(ky.username) DisplayUsernames();
  126.         if(ky.blank) stopBlankFuckers();
  127.        
  128.         var end = performance.now();
  129.         var time = end - start;
  130.         console.log('CMod execution time: ' + Math.round(time * 100) / 100 + " miliseconds");
  131.     }
  132. );
  133.  
  134. function colonelGift(){
  135.     var miniprofiles = document.querySelectorAll(".mini-profile");
  136.     var match = "@colonelj";
  137.    
  138.     if(miniprofiles.length < 1) return;
  139.     for (i=0; i<miniprofiles.length; i++){
  140.         var mp = miniprofiles[i];
  141.         var un = "";
  142.         try {
  143.             un = mp.querySelector("a").getAttribute("title");
  144.         }catch(err){}
  145.         if (un == match){
  146.             mp = mp.parentNode.parentNode.parentNode.parentNode.parentNode;
  147.             mp.style.backgroundImage = "url(http://i.imgur.com/gEJkDqv.png)";
  148.         }
  149.     }
  150. }
  151.  
  152.  
  153. //Toggle panel visibility
  154. function PanelToggle() {
  155.     var pop = document.getElementById("cmod-wrapper");
  156.  
  157.     if (pop.style.display == "none" || pop.style.display == "") {
  158.         document.getElementById("panelButton").childNodes[0].nodeValue = "Hide CMod Panel";
  159.         pop.style.display = "block";
  160.     } else {
  161.         document.getElementById("panelButton").childNodes[0].nodeValue = "Show CMod Panel";
  162.         pop.style.display = "none";
  163.     }
  164. }
  165.  
  166. function stopBlankFuckers(){
  167.     for (x = 0; x < document.getElementsByClassName("user-link").length; x++){
  168.         var y = document.getElementsByClassName("user-link")[x].innerHTML.trim();
  169.         y = removeZWS(y);
  170.         if(y == ""){
  171.                document.getElementsByClassName("user-link")[x].innerHTML = document.getElementsByClassName("user-link")[x].title;
  172.         }
  173.     }
  174.    
  175.     for (x = 0; x < $('.user-link span').size(); x++){
  176.         var y = $('.user-link span')[x].innerHTML.trim();
  177.         y = removeZWS(y);
  178.         if(y == ""){
  179.                $('.user-link span')[x].innerHTML = $('.user-link span')[x].parentNode.title;
  180.         }
  181.     }
  182. }
  183.  
  184. //Saves CMod panel options to the key and pushes key to PB
  185. function Save() {
  186.     PanelToggle();
  187.    
  188.     ky.plimit = document.getElementById("cmod-post-limit").value;
  189.     ky.slimit = document.getElementById("cmod-sig-limit").value;
  190.  
  191.     if (document.getElementById("cmod-bpost-0").checked == true) ky.bpost = 0;
  192.     if (document.getElementById("cmod-bpost-1").checked == true) ky.bpost = 1;
  193.     if (document.getElementById("cmod-bpost-2").checked == true) ky.bpost = 2;
  194.     if (document.getElementById("cmod-bpost-3").checked == true) ky.bpost = 3;
  195.  
  196.     if (document.getElementById("cmod-bthread-0").checked == true) ky.bthread = 0;
  197.     if (document.getElementById("cmod-bthread-1").checked == true) ky.bthread = 1;
  198.     if (document.getElementById("cmod-bthread-2").checked == true) ky.bthread = 2;
  199.  
  200.     ky.clr = document.getElementById("cmod-color").value;
  201.    
  202.     if (document.getElementById("cmod-username").checked == true){
  203.         ky.username = 1;
  204.     }else{
  205.         ky.username = 0;
  206.     }
  207.    
  208.     if (document.getElementById("cmod-blank").checked == true){
  209.         ky.blank = 1;
  210.     }else{
  211.         ky.blank = 0;
  212.     }
  213.    
  214.     if (document.getElementById("cmod-holiday").checked == true){
  215.         ky.holiday = 1;
  216.     }else{
  217.         ky.holiday = 0;
  218.     }
  219.    
  220.     if (document.getElementById("cmod-twitch-0").checked == true) ky.twitch = 0;
  221.     if (document.getElementById("cmod-twitch-1").checked == true) ky.twitch = 1;
  222.     if (document.getElementById("cmod-twitch-2").checked == true) ky.twitch = 2;
  223.    
  224.     pb.plugin.key('cmod_options').set({
  225.         value: ky
  226.     });
  227. }
  228.  
  229. //Loads key values into the CMod Panel
  230. function LoadKey() {
  231.     document.getElementById("cmod-post-limit").value = ky.plimit;
  232.     document.getElementById("cmod-sig-limit").value = ky.slimit;
  233.    
  234.     switch (ky.bpost) {
  235.         case 0:
  236.             document.getElementById("cmod-bpost-0").checked = true;
  237.             break;
  238.         case 1:
  239.             document.getElementById("cmod-bpost-1").checked = true;
  240.             break;
  241.         case 2:
  242.             document.getElementById("cmod-bpost-2").checked = true;
  243.             break;
  244.         case 3:
  245.             document.getElementById("cmod-bpost-3").checked = true;
  246.             break;
  247.     }
  248.     switch (ky.bthread) {
  249.         case 0:
  250.             document.getElementById("cmod-bthread-0").checked = true;
  251.             break;
  252.         case 1:
  253.             document.getElementById("cmod-bthread-1").checked = true;
  254.             break;
  255.         case 2:
  256.             document.getElementById("cmod-bthread-2").checked = true;
  257.             break;
  258.     }
  259.     document.getElementById("cmod-color").value = ky.clr;
  260.     if(ky.username == 1){
  261.         document.getElementById("cmod-username").checked = true;
  262.     }
  263.     if(ky.blank == 1){
  264.         document.getElementById("cmod-blank").checked = true;
  265.     }
  266.     if(ky.holiday == 1){
  267.         document.getElementById("cmod-holiday").checked = true;
  268.     }
  269.     switch (ky.twitch) {
  270.         case 0:
  271.             document.getElementById("cmod-twitch-0").checked = true;
  272.             break;
  273.         case 1:
  274.             document.getElementById("cmod-twitch-1").checked = true;
  275.             break;
  276.         case 2:
  277.             document.getElementById("cmod-twitch-2").checked = true;
  278.             break;
  279.     }
  280. }
  281.  
  282. //Adds class to the blocked threads added by another plugin.
  283. function BlockThreadClass() {
  284.     try {
  285.         var tdArr = document.getElementsByClassName("list")[0].getElementsByTagName("td");
  286.  
  287.         for (i = 0; i < tdArr.length; ++i) {
  288.             if (tdArr[i].getAttribute("colspan") == 7) {
  289.                 tdArr[i].className = "blocked-thread";
  290.             }
  291.         }
  292.     }catch(err){console.log(err);}
  293. }
  294.  
  295. //Gets user key and fills with default values if any are missing. Sets a default key of no user is logged in.
  296. function GetUserKey(){
  297.     if (userID != 0) {
  298.         ky = pb.plugin.key('cmod_options').get();
  299.         var pass = 1;
  300.        
  301.         if (ky == undefined) {
  302.             pass = 0
  303.             ky = {
  304.                 "plimit": 950,
  305.                 "slimit": 400,
  306.                 "bpost": 0,
  307.                 "bthread": 0,
  308.                 "clr": "#8B0000",
  309.                 "blank":0,
  310.                 "username": 0,
  311.                 "enabled": 1,
  312.                 "holiday": 1,
  313.                 "twitch": 1
  314.             };
  315.         }else{
  316.             if(ky.plimit == undefined){
  317.                 pass = 0;
  318.                 ky.plimit = 950;
  319.             }
  320.             if(ky.slimit == undefined){
  321.                 pass = 0;
  322.                 ky.slimit = 400;
  323.             }
  324.             if(ky.bpost == undefined){
  325.                 pass = 0;
  326.                 ky.bpost = 0;
  327.             }
  328.             if(ky.blank == undefined){
  329.                 pass = 0;
  330.                 ky.blank = 0;
  331.             }
  332.             if(ky.bthread == undefined){
  333.                 pass = 0;
  334.                 ky.bthread = 0;
  335.             }
  336.             if(ky.clr == undefined){
  337.                 pass = 0;
  338.                 ky.clr = "#8B0000";
  339.             }
  340.             if(ky.username == undefined){
  341.                 pass = 0;
  342.                 ky.username = 0;
  343.             }
  344.             if(ky.enabled == undefined){
  345.                 pass = 0;
  346.                 ky.enabled = 1;
  347.             }  
  348.             if(ky.holiday == undefined){
  349.                 pass = 0;
  350.                 ky.holiday = 1;
  351.             }
  352.             if(ky.twitch == undefined){
  353.                 pass = 0;
  354.                 ky.twitch = 1;
  355.             }          
  356.         }
  357.        
  358.         if(pass == 0){
  359.             pb.plugin.key('cmod_options').set({
  360.                 value: ky
  361.             })
  362.             ky = pb.plugin.key('cmod_options').get();
  363.         }
  364.     } else {
  365.         ky = {
  366.             "plimit": 950,
  367.             "slimit": 400,
  368.             "bpost": 0,
  369.             "bthread": 0,
  370.             "clr": "#8B0000",
  371.             "blank":0,
  372.             "username": 0,
  373.             "enabled": 1,
  374.             "holiday": 1,
  375.             "twitch": 1
  376.         };
  377.     }
  378. }
  379.  
  380. //Checks if on settings page, and adds Enable button if yes.
  381. function EnabledSettings(){
  382.     var metas = document.getElementsByTagName('meta');  
  383.     var settingsPage = 0;
  384.     for (i=0; i<metas.length; i++) {
  385.         if (metas[i].getAttribute("property") == "og:title") {
  386.             if (metas[i].getAttribute("content") == "Edit Profile | General Discussion"){
  387.                 settingsPage = 1;
  388.             }
  389.         }
  390.     }
  391.    
  392.     if(settingsPage == 1){
  393.         var settingForm = document.querySelector(".form_user_edit_settings");
  394.         var enableBtn = document.createElement('input');
  395.         enableBtn.setAttribute("type", "button");
  396.         enableBtn.setAttribute("id", "cmod-enable");
  397.         if(ky.enabled == 1){
  398.             enableBtn.setAttribute("value", "Disable CMod (refresh to apply)");
  399.             enableBtn.addEventListener("click", function(){
  400.                 ky.enabled = 0;
  401.                 pb.plugin.key('cmod_options').set({
  402.                     value: ky
  403.                 });
  404.             });
  405.         }else{
  406.             enableBtn.setAttribute("value", "Enable CMod (refresh to apply)");
  407.             enableBtn.addEventListener("click", function(){
  408.                 ky.enabled = 1;
  409.                 pb.plugin.key('cmod_options').set({
  410.                     value: ky
  411.                 });
  412.             });
  413.         }
  414.         settingForm.appendChild(enableBtn);
  415.     }
  416. }
  417.  
  418. function DisplayUsernames(){
  419.     var miniprofiles = document.querySelectorAll(".mini-profile");
  420.    
  421.     if(miniprofiles.length < 1) return;
  422.    
  423.     for (i=0; i<miniprofiles.length; i++){
  424.         var mp = miniprofiles[i];
  425.         if(mp.className.indexOf("un-added") > -1) continue;
  426.         var un = "";
  427.         try {un = mp.querySelector("a").getAttribute("title");}catch(err){}
  428.        
  429.         mp.insertBefore(document.createElement("div"), mp.children[1]);
  430.         mp.insertBefore(document.createTextNode("\n" + un), mp.children[2]);
  431.         mp.className = mp.className + " un-added";
  432.     }
  433. }
  434.  
  435. function PlayerUnfuck(){
  436.     var players = document.querySelectorAll(".imgur-embed");
  437.    
  438.     for (i=0; i<players.length; i++){
  439.         if(players[i].hasAttribute("controls")) continue;
  440.        
  441.         players[i].setAttribute("controls","");
  442.     }
  443.    
  444.     var eww = document.querySelectorAll(".embed-video-overlay");
  445.    
  446.     for (i=0; i<eww.length; i++){
  447.         eww[i].parentElement.removeChild(eww[i]);
  448.     }
  449. }
  450.  
  451. function Hattify(){
  452.     var miniprofiles = document.querySelectorAll(".mini-profile");
  453.    
  454.     if(miniprofiles.length < 1) return;
  455.    
  456.     for (i=0; i<miniprofiles.length; i++){
  457.         var mp = miniprofiles[i];
  458.         var mpheight = $(mp).height();
  459.         var topoff = (-1 * $(mp).height()) - 50;
  460.        
  461.         if(mp.className.indexOf("hat-added") > -1) continue;
  462.        
  463.         var hat = document.createElement("img");
  464.         hat.src = "http://i.imgur.com/9j9D1FH.png";
  465.         hat.style.position = "relative";
  466.         hat.style.top = topoff.toString() + "px";
  467.         hat.style.left = "-58px";
  468.         hat.style.display = "inline-block";
  469.         hat.style.zIndex = "200";
  470.        
  471.         var mpheight = $(mp).height();
  472.        
  473.         try{
  474.             if(mp.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[3].className.indexOf("blocked") > -1){
  475.                 continue;
  476.             }
  477.         }catch(err){}
  478.         mp.appendChild(hat);
  479.         mp.className = mp.className + " hat-added";
  480.         mp.style.height = mpheight.toString() + "px";
  481.        
  482.         mp.children[0].style.position = "relative";
  483.         mp.children[0].style.zIndex = "201";
  484.        
  485.         mp.style.overflow = "visible";
  486.         mp = mp.parentNode;
  487.         mp.style.overflow = "visible";
  488.         mp = mp.parentNode;
  489.         mp.style.overflow = "visible";
  490.         mp = mp.parentNode;
  491.         mp.style.overflow = "visible";
  492.         mp = mp.parentNode;
  493.         mp.style.overflow = "visible";
  494.         mp = mp.parentNode;
  495.         mp.style.overflow = "visible";
  496.         mp = mp.parentNode;
  497.         mp.style.overflow = "visible";
  498.         mp = mp.parentNode;
  499.         mp.style.overflow = "visible";
  500.         mp = mp.parentNode;
  501.         mp.style.overflow = "visible";
  502.         mp = mp.parentNode;
  503.         mp.style.overflow = "visible";
  504.         mp = mp.parentNode;
  505.         mp.style.overflow = "visible";
  506.         mp = mp.parentNode;
  507.         mp.style.overflow = "visible";
  508.         mp = mp.parentNode;
  509.         mp.style.overflow = "visible";
  510.     }
  511. }
  512.  
  513. function removeZWS(input){
  514.     return input.replace(/\u200B/g,'');  
  515. }
  516.  
  517. function TwitchHandling(){
  518.     if(ky.twitch == "0") return;
  519.    
  520.     var iframes = document.getElementsByTagName("iframe");
  521.     for (i = 0; i < iframes.length; ++i) {
  522.         if(iframes[i].getAttribute("src") == null) continue;
  523.         if(iframes[i].getAttribute("src").indexOf("http://www.twitch.tv") < 0) continue;
  524.        
  525.         var link = iframes[i].getAttribute("src").substring(0, iframes[i].getAttribute("src").length - 6);
  526.         var channel = link.substring(21);
  527.        
  528.         var replacement;
  529.         if(ky.twitch == "2"){
  530.             replacement = document.createElement("a");
  531.             replacement.appendChild(document.createTextNode(link));
  532.             replacement.href = link;
  533.         }
  534.         if(ky.twitch == "1"){
  535.             replacement = document.createElement("object");
  536.             var objectHTML = '<param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><param name="allowNetworking" value="all"/><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf"/><param name="flashvars" value="hostname=www.twitch.tv&channel=' + channel + '&auto_play=false&start_volume=25"/>';
  537.            
  538.             replacement.setAttribute("style", "opacity:1;");
  539.             replacement.setAttribute("type", "application/x-shockwave-flash");
  540.             replacement.setAttribute("height", "300");
  541.             replacement.setAttribute("width", "400");
  542.             replacement.setAttribute("data", "http://www.twitch.tv/widgets/live_embed_player.swf");
  543.             replacement.setAttribute("bgcolor", "#000000");
  544.            
  545.             replacement.innerHTML = objectHTML;
  546.         }
  547.        
  548.         iframes[i].parentNode.replaceChild(replacement, iframes[i]);
  549.     }
  550. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement