Advertisement
Guest User

gomoroshiner.js

a guest
Jan 5th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        gomoroshiner
  3. // @namespace   g0moroshiner
  4. // @icon        http://i.imgur.com/GPqOP3o.png
  5. // @version     1
  6. // @grant       none
  7. // @match        *://2ch.hk/*
  8. // ==/UserScript==
  9.  
  10. function addJQuery(callback) {
  11.   var script = document.createElement("script");
  12.   script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  13.   script.addEventListener('load', function() {
  14.     var script = document.createElement("script");
  15.     script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
  16.     document.body.appendChild(script);
  17.   }, false);
  18.   document.body.appendChild(script);
  19. }
  20.  
  21. var elements, postid, replyid;
  22.  
  23. setInterval(function main() {
  24.   elements = document.getElementsByClassName("post-details");
  25.    for (i = 0; i < elements.length; i++) {
  26.     postid = "post-body-";
  27.      for (l = 0; l < 4; l++){
  28.         if (elements[i].getElementsByTagName("span")[l].innerHTML == "!!lmotSi2gK." && elements[i].getElementsByTagName("checkedg").length == 0){
  29.           postid = postid + elements[i].id.match(/\d+/);
  30.           replyid = document.getElementById(postid).getElementsByTagName("blockquote")[0].getElementsByTagName("a");
  31.           if (replyid.length > 0){
  32.             replyid = document.getElementById(postid).getElementsByTagName("blockquote")[0].getElementsByTagName("a")[0].innerHTML.match(/\d+/);
  33.             document.getElementById(postid).getElementsByTagName("blockquote")[0].innerHTML = "<a href=\"" + "/es/res" + document.URL.match(/\d+/g)[1] + ".html" + "#" + replyid + "\"" + " class=\"post-reply-link\"" +
  34.                                                                 " data-thread=" + "\"" + document.URL.match(/\d+/g)[1] + "\"" + " data-num=\"" + replyid + "\"" + ">" + ">>" + replyid + "</a><br>А ещё я сосу хуи.";      
  35.           }
  36.           else{
  37.             document.getElementById(postid).getElementsByTagName("blockquote")[0].innerHTML = "А ещё я сосу хуи.";    
  38.           }      
  39.           postid = "post-details-" + elements[i].id.match(/\d+/);
  40.           document.getElementById(postid).innerHTML += "<checkedg></checkedg>"; // добавляем в конец тэг, чтобы скрипт не менял каждый раз одни и те же посты и не вызывал лаги
  41.         }
  42.      }
  43.    }
  44. }, 500);
  45.  
  46. $(document).ready(addJQuery(main));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement