Advertisement
KarachanStyler

Licznik+

Sep 5th, 2018
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function jebanie(){
  2.         chuj = $("#watched_list").find(".watch-link");
  3.         for (i=0; i<chuj.length; i++){
  4.                 c = chuj[i];
  5.                 dupa = $(c).find('.unreadPostsNumber')[0];
  6.                 if ($(dupa).text().search('[0]') == -1 && $(dupa).text().search("Ɓadowanie") == -1) {
  7.                         $(dupa).css('color', 'lime');
  8.                 }
  9.                 else{
  10.                         $(dupa).css('color', '');
  11.                 }
  12.         }
  13. }
  14.  
  15.  
  16. function callback(mutationList){
  17.         jebanie();
  18. }
  19.  
  20. $(document).ready(function(){
  21.         sraka = document.getElementById('watched_list');
  22.         guwno = { childList: true, subtree: true, characterData: true };
  23.         kutas = new MutationObserver(callback);
  24.         kutas.observe(sraka, guwno);
  25. });
  26.  
  27.  
  28. (() => {
  29.     let addCSS = (css) => {
  30.         var c = document.createElement("style");
  31.         c.type = "text/css";
  32.         c.innerHTML = css;
  33.         document.head.appendChild(c);
  34.     };
  35.  
  36.     let observer = new MutationObserver(muts => {
  37.         muts.forEach(mut => {
  38.             if (mut.target.classList.contains("unreadPostsNumber")) {
  39.                 let unreadPosts = parseInt(mut.addedNodes[0].nodeValue.trim().match(/\[(\d+)\]/)[1]);
  40.                 let entry_id = mut.target.parentNode.parentNode.getAttribute("id");
  41.                 addCSS(`#${entry_id} { order: -${unreadPosts}};`); // magic
  42.             }
  43.         });
  44.     });
  45.  
  46.     $(() => {
  47.         addCSS(`
  48. #watched_list {
  49.     display: flex;
  50.     flex-direction: column;
  51. }`);
  52.         observer.observe(document.getElementById("watcher_box"), {childList: true, subtree: true});
  53.     });
  54. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement