Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         avecrypto
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       anonymousse
  7. // @match        https://avenoel.org/*
  8. // @exclude      https://avenoel.org/chat*
  9. // @exclude      https://avenoel.org/admin*
  10. // @grant        none
  11. // ==/UserScript==
  12.  
  13. const START_DELIMITER = '#secret#start#';
  14. const END_DELIMITER = '#secret#end#';
  15. const EQUAL_SUBSTITUTOR = '#equal#';
  16. const SUBSTITUTORS = [
  17.     ['=', '#EQUAL#'],
  18.     ['+', '#PLUS#'],
  19.     ['/', '#SLASH#'],
  20. ];
  21.  
  22. const CRYPTO_REGEXP = new RegExp(`${START_DELIMITER}([a-zA-Z0-9#]+)${END_DELIMITER}`);
  23.  
  24. function getSelection (field) {
  25.     return field.value.substring(field.selectionStart, field.selectionEnd);
  26. }
  27.  
  28. function replaceSelection (field, new_value) {
  29.     field.value = [field.value.slice(0, field.selectionStart), new_value, field.value.slice(field.selectionEnd)].join('');
  30. }
  31.  
  32. (function() {
  33.     'use strict';
  34.  
  35.     let bbcodes = $('.bbcodes');
  36.  
  37.     let button = $('<button type="button" class="btn" tabindex="-1" href="#">');
  38.     let img = $('<img src="https://avenoel.org/images/smilies/724771109.gif">');
  39.  
  40.     img.appendTo(button);
  41.  
  42.     button.click(function () {
  43.         let field = $(this).closest('form').find('textarea')[0];
  44.  
  45.         console.log(field);
  46.         if (field.selectionStart === field.selectionEnd) {
  47.             return ;
  48.         }
  49.         let msg = getSelection(field);
  50.         let encoded = SUBSTITUTORS.reduce((acc, v) => acc.replace(new RegExp(v[0], 'g'), v[1]), btoa(msg));
  51.         replaceSelection(field, `<color=${START_DELIMITER}${encoded}${END_DELIMITER}> </color>`);
  52.     });
  53.  
  54.     button.appendTo(bbcodes);
  55.  
  56.     if (document.location.pathname.split('/')[1] === 'topic') {
  57.         $('.text-color').filter(function () {
  58.             return CRYPTO_REGEXP.test($(this).attr('style'));
  59.         }).each(function () {
  60.             let encoded = $(this).attr('style').match(CRYPTO_REGEXP)[1].replace(new RegExp(EQUAL_SUBSTITUTOR, 'g'), '=');
  61.             console.log(encoded);
  62.             let msg = atob(SUBSTITUTORS.reduce((acc, v) => acc.replace(new RegExp(v[1], 'g'), v[0]), encoded));
  63.             $.post('https://avenoel.org/previsualisation', {content: `Message Avepremium: <spoiler>${msg}</spoiler>`}).done(res => {
  64.                     $(this).html(res.content);
  65.             });
  66.         });
  67.     }
  68. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement