Guest User

Powiadamiacz.ork

a guest
Jul 20th, 2022
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var allMyPosts = document.getElementsByClassName("highlightPost");
  2. var allReplies = 0;
  3. var sawReplies = 0;
  4. var responded = false;
  5.  
  6. for (let i = 0; i < allMyPosts.length; i++) {
  7.     if (allMyPosts[i].getElementsByClassName("backlink")[0].innerText.length > 0) {
  8.         sawReplies += 1;
  9.     }
  10. }
  11.  
  12. function containsNumber(str) {
  13.     return /\d/.test(str);
  14. }
  15.  
  16. const changeFavicon = link => {
  17.     let $favicon = document.querySelector('link[rel="icon"]');
  18.     if ($favicon !== null) {
  19.         $favicon.href = link;
  20.     } else {
  21.         $favicon = document.createElement("link");
  22.         $favicon.rel = "icon";
  23.         $favicon.href = link;
  24.         document.head.appendChild($favicon);
  25.     }
  26. }
  27.  
  28. window.setInterval(function () {
  29.     let newPosts = 0;
  30.  
  31.     if (containsNumber(document.title[1])) {
  32.         let num = document.title[1];
  33.         if (containsNumber(document.title[2])) num += document.title[2];
  34.         if (containsNumber(document.title[3])) num += document.title[3];
  35.         num = parseInt(num);
  36.         if (num > newPosts) newPosts = num;
  37.  
  38.         allMyPosts = document.getElementsByClassName("highlightPost");
  39.  
  40.         for (let i = 0; i < allMyPosts.length; i++) {
  41.             if (allMyPosts[i].getElementsByClassName("backlink")[0].innerText.length > 0) allReplies += 1;
  42.         }
  43.  
  44.         if (allReplies > sawReplies) {
  45.             responded = true;
  46.         }
  47.     }
  48.     else {
  49.         sawReplies = allReplies;
  50.         responded = false;
  51.     }
  52.  
  53.     if (responded) changeFavicon("https://i.ibb.co/8DbD9S2/cbimage.gif");
  54.     else changeFavicon("https://karachan.org/favicon.ico");
  55. }, 5000);
Advertisement
Add Comment
Please, Sign In to add comment