fanex

Untitled

Apr 30th, 2020
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         RemoveCommentsAndMentions
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Удаляет комментарии Читателя1111 и комментарии с обращением к нему
  6. // @author       Styx
  7. // @match        https://fanfics.me/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function(win, $) {
  12.     'use strict';
  13.  
  14.     const hideMentions = 0;
  15.  
  16.     const hideUIDs = [
  17.         '56033',
  18.         '202713',
  19.     ];
  20.  
  21.     const re = /#(MessageCommentsNext|messagenextcomments)/;
  22.  
  23.     $(function() {
  24.  
  25.         function removeComments() {
  26.             hideUIDs.forEach(function(uid) {
  27.                 const q = [
  28.                     `.MessageRightUser > span[data-show-member="${uid}"]`
  29.                 ];
  30.                 if (hideMentions) {
  31.                     q.push( `.MessageText a.user[href$="/user${uid}"]` );
  32.                 }
  33.                 $( q.join(', ') ).closest('table.Message').remove();
  34.             });
  35.         };
  36.  
  37.         win._php_success2 = win.php.success;
  38.         win.php.success = function (_a, _b) {
  39.             var _ = JSON.stringify(_a);
  40.             if (re.test(_)) {
  41.                 setTimeout(removeComments, 1);
  42.             }
  43.             _php_success2(_a, _b);
  44.         };
  45.  
  46.         removeComments();
  47.  
  48.         win.console.info(`RCaM: remove comments ${hideMentions?'and mentions ':''}of ${hideUIDs.length} user${hideUIDs.length!=1?'s':''}`);
  49.     });
  50.  
  51. })(window, jQuery);
Advertisement
Add Comment
Please, Sign In to add comment