Guest User

Untitled

a guest
Dec 22nd, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ПУК-СРЕНЬК
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       Anonymous
  7. // @match        https://2ch.hk/*/res/*.html
  8. // @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. const decode = (str) => {
  13.     return new TextDecoder().decode(
  14.         new Uint8Array(
  15.             str
  16.             .replace(/(\d+[ПУК|СРЕНЬК]{3,6})/g, (m) => {
  17.                 const count = parseInt(m.replace(/[ПУК|СРЕНЬК]/g, ""), 10);
  18.                 return m.replace(count, "").repeat(count);
  19.             })
  20.             .replace(/ПУК/g, "0")
  21.             .replace(/СРЕНЬК/g, "1")
  22.             .replace(/-/g, "")
  23.             .match(/.{1,8}/g)
  24.             .map((c) => parseInt(c, 2))
  25.         )
  26.     );
  27. };
  28.  
  29. (function() {
  30.     const posts = document.querySelectorAll('.post__message');
  31.  
  32.     posts.forEach((post) => {
  33.         const words = post.textContent.replace(/\t+/g,"").split(/[\n, ]+/);
  34.  
  35.         words.forEach((word) => {
  36.             post.innerHTML = post.innerHTML.replace(/(\d+)?(СРЕНЬК|ПУК).+/, (m) => {
  37.                 return `<div style="color:green">${decode(m)}</div>`;
  38.             });
  39.         });
  40.     });
  41. })();
Add Comment
Please, Sign In to add comment