Advertisement
ncp99

parashautoreplace.user.js

Nov 2nd, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ParashAutoReplace
  3. // @version      0.1
  4. // @description  ParashAutoReplace
  5. // @author       You
  6. // @downloadURL https://pastebin.com/raw/tfsXs8wJ
  7. // @updateURL   https://pastebin.com/raw/tfsXs8wJ
  8. // @match        https://2ch.hk/po/*
  9. // @grant        unsafeWindow
  10. // ==/UserScript==
  11.  
  12. (function(window) {
  13.     'use strict';
  14.  
  15.     function replace(str) {
  16.         return str
  17.             .replace(/Светов/gi, 'Све​тов')
  18.             .replace(/Навальный/gi, 'Навал​ьный')
  19.             .replace(/Путин/gi, 'Светов');
  20.     }
  21.  
  22.     var send = XMLHttpRequest.prototype.send;
  23.     var open = XMLHttpRequest.prototype.open;
  24.     XMLHttpRequest.prototype.send = function(data) {
  25.         try {
  26.             if (this._method == 'POST' && this._url && this._url.indexOf('posting') != 0 && data.has('comment')) {
  27.                 var comment = data.get('comment');
  28.                 data.set('comment', replace(comment));
  29.             }
  30.         } catch(e) {
  31.             console.log(e);
  32.         }
  33.  
  34.         return send.apply(this, arguments);
  35.     };
  36.     XMLHttpRequest.prototype.open = function(method, url, obj) {
  37.         this._method = method;
  38.         this._url = url;
  39.         return open.apply(this, arguments);
  40.     };
  41.  
  42. })(unsafeWindow);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement