Wykop X JS

Michał Białek znowu zepsuł mirko (⌐ ͡■ ͜ʖ ͡■)

As of 2023-01-30. See the latest version.

  1. // ==UserScript==
  2. // @name Wykop X JS
  3. // @namespace Violentmonkey Scripts
  4. // @match https://wykop.pl/*
  5.  
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  7. // @grant GM_addStyle
  8.  
  9. // @version 1.2.3
  10. // @author SebastianDosiadłgo <sebastianpodsiadlo5@gmail.com>
  11. // @description Michał Białek znowu zepsuł mirko (⌐ ͡■ ͜ʖ ͡■)
  12. // @license Copy anything you want
  13. // @license Każdy może skopiować dowolny fragment tego kodu i używać go do woli. Każdy oprócz użytkownika @browarek.
  14. // @license @browarek aka 'vocus', który kradnie cudzy kod, a potem się wyzywa i twierdzi, że wcale nic nie ukradł XD nie może skopiować stąd nawet przecinka.
  15.  
  16. // ==/UserScript==
  17.  
  18.  
  19. function countNumberOfNotificationsWithDelay()
  20. {
  21. setTimeout(function(){countNumberOfNotifications()}, 1000);
  22. }
  23. function countNumberOfNotifications()
  24. {
  25. $("header .right ul li.dropdown").removeClass("unread_5").removeClass("unread_4").removeClass("unread_3").removeClass("unread_2").removeClass("unread_1");
  26. $("header .right ul li.dropdown:has(a.new)" ).each(function(index, value)
  27. {
  28. let numberOfNotifications = 0;
  29. // liczba powiadomień o tagach / wołaniach
  30. $(this).find(".notify:not(.read)" ).each(function(index, value)
  31. {
  32. ++numberOfNotifications;
  33. $(this).addClass(`unread_${numberOfNotifications}`);
  34. }).parents(`.notifications.dropdown`).addClass(`unread_${numberOfNotifications}`);
  35.  
  36. // liczba powiadomień o wiadomościach PM
  37. $(this).find(".item.unread" ).each(function(index, value)
  38. {
  39. ++numberOfNotifications;
  40. $(this).addClass(`unread_${numberOfNotifications}`);
  41. }).parents(`.pm.dropdown`).addClass(`unread_${numberOfNotifications}`);
  42. console.log(`[Wykop X]: liczba powiadomień: ${numberOfNotifications}`);
  43. })
  44. }
  45.  
  46.  
  47.  
  48.  
  49. navigation.addEventListener('navigate', (event) => { countNumberOfNotificationsWithDelay()});
  50. window.onload = function(event) { countNumberOfNotificationsWithDelay(); };
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. // waitForKeyElements("section.stream div.content section.entry div.comments section.entry-subcomments div.content section.reply", sortCommentsByID);
  62. waitForKeyElements(`section.filter h3[data-dropdown="filter-dropdown-period"]`, unrollDropdowns);
  63. document.removeEventListener('click', this.documentClick)
  64.  
  65. function unrollDropdowns(dropdown)
  66. {
  67. console.log("Wykop X :: unrollDropdowns")
  68. console.log(dropdown)
  69. dropdown.click();
  70. }
  71.  
  72. function sortCommentsByID(comment)
  73. {
  74. var commentID = comment.attr ("id").substr(8, 9);
  75. console.log(commentID);
  76. comment.css("order", commentID);
  77. }
  78.  
  79.  
  80.  
  81. /* browarek programisto piekielny, przestań mi kurka kod prześladować! */
  82.  
  83.  
  84. /* https://gist.github.com/BrockA/2625891 */
  85. /*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
  86. that detects and handles AJAXed content.
  87. Usage example:
  88. waitForKeyElements (
  89. "div.comments"
  90. , commentCallbackFunction
  91. );
  92. //--- Page-specific function to do what we want when the node is found.
  93. function commentCallbackFunction (jNode) {
  94. jNode.text ("This comment changed by waitForKeyElements().");
  95. }
  96. IMPORTANT: This function requires your script to have loaded jQuery.
  97. */
  98. function waitForKeyElements (
  99. selectorTxt, /* Required: The jQuery selector string that
  100. specifies the desired element(s).
  101. */
  102. actionFunction, /* Required: The code to run when elements are
  103. found. It is passed a jNode to the matched
  104. element.
  105. */
  106. bWaitOnce, /* Optional: If false, will continue to scan for
  107. new elements even after the first match is
  108. found.
  109. */
  110. iframeSelector /* Optional: If set, identifies the iframe to
  111. search.
  112. */
  113. ) {
  114. var targetNodes, btargetsFound;
  115.  
  116. if (typeof iframeSelector == "undefined")
  117. targetNodes = $(selectorTxt);
  118. else
  119. targetNodes = $(iframeSelector).contents ()
  120. .find (selectorTxt);
  121.  
  122. if (targetNodes && targetNodes.length > 0) {
  123. btargetsFound = true;
  124. /*--- Found target node(s). Go through each and act if they
  125. are new.
  126. */
  127. targetNodes.each ( function () {
  128. var jThis = $(this);
  129. var alreadyFound = jThis.data ('alreadyFound') || false;
  130.  
  131. if (!alreadyFound) {
  132. //--- Call the payload function.
  133. var cancelFound = actionFunction (jThis);
  134. if (cancelFound)
  135. btargetsFound = false;
  136. else
  137. jThis.data ('alreadyFound', true);
  138. }
  139. } );
  140. }
  141. else {
  142. btargetsFound = false;
  143. }
  144.  
  145. //--- Get the timer-control variable for this selector.
  146. var controlObj = waitForKeyElements.controlObj || {};
  147. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  148. var timeControl = controlObj [controlKey];
  149.  
  150. //--- Now set or clear the timer as appropriate.
  151. if (btargetsFound && bWaitOnce && timeControl) {
  152. //--- The only condition where we need to clear the timer.
  153. clearInterval (timeControl);
  154. delete controlObj [controlKey]
  155. }
  156. else {
  157. //--- Set a timer, if needed.
  158. if ( ! timeControl) {
  159. timeControl = setInterval ( function () {
  160. waitForKeyElements ( selectorTxt,
  161. actionFunction,
  162. bWaitOnce,
  163. iframeSelector
  164. );
  165. },
  166. 300
  167. );
  168. controlObj [controlKey] = timeControl;
  169. }
  170. }
  171. waitForKeyElements.controlObj = controlObj;
  172. }