Konf

Скрипт для 2ch.hk: Горячая кнопка скрыть пост (Ctrl + Alt + ;)

Apr 18th, 2021 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Горячая кнопка скрыть пост: Ctrl + Alt + ;
  3. // @version      1
  4. // @author       Konf
  5. // @namespace    https://greasyfork.org/ru/users/462954
  6. // @icon         https://www.google.com/s2/favicons?domain=2ch.hk
  7. // @include      /^https:\/\/2ch\.(hk|pm)\/.*/
  8. // @run-at       document-start
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. /* jshint esversion: 6 */
  13. /* global Post */
  14.  
  15. (function() {
  16.   'use strict';
  17.  
  18.   window.addEventListener('keydown', ev => {
  19.     if (!ev.altKey || !ev.ctrlKey || ev.code !== 'Semicolon') return;
  20.  
  21.     const nodesUnderCursor = document.querySelectorAll(':hover');
  22.    
  23.     for (const node of nodesUnderCursor) {
  24.       if (node.matches('.post')) {
  25.         const postId = node.dataset.num;
  26.         const postInstance = Post(postId);
  27.  
  28.         // 2ch built-in methods
  29.         postInstance.hide(); // hide visually right now
  30.         Post(postId)._storeHide(); // remember for hiding after page reload
  31.  
  32.         break;
  33.       }
  34.     }
  35.   });
  36. })();
  37.  
Add Comment
Please, Sign In to add comment