Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
79
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 CRYPTO_KEY = 'AVEPREMIUMCTROCOOLISSOUFLE';
  14. const START_DELIMITER = '#secret#start#';
  15. const END_DELIMITER = '#secret#end#';
  16. const EQUAL_SUBSTITUTOR = '#equal#';
  17.  
  18. const CRYPTO_REGEXP = new RegExp(`${START_DELIMITER}([a-zA-Z0-9#]+)${END_DELIMITER}`);
  19.  
  20. function getSelection (field) {
  21.     return field.value.substring(field.selectionStart, field.selectionEnd);
  22. }
  23.  
  24. function replaceSelection (field, new_value) {
  25.     field.value = [field.value.slice(0, field.selectionStart), new_value, field.value.slice(field.selectionEnd)].join('');
  26. }
  27.  
  28. (function() {
  29.     'use strict';
  30.  
  31.     let bbcodes = $('.bbcodes');
  32.  
  33.     let button = $('<button type="button" class="btn" tabindex="-1" href="#">');
  34.     let img = $('<img src="https://avenoel.org/images/smilies/724771109.gif">');
  35.  
  36.     img.appendTo(button);
  37.  
  38.     button.click(function () {
  39.         let field = $(this).closest('form').find('textarea')[0];
  40.  
  41.         console.log(field);
  42.         if (field.selectionStart === field.selectionEnd) {
  43.             return ;
  44.         }
  45.         let msg = getSelection(field);
  46.         let encoded = btoa(msg).replace(/=/g, EQUAL_SUBSTITUTOR);
  47.         replaceSelection(field, `<color=${START_DELIMITER}${encoded}${END_DELIMITER}> </color>`);
  48.     });
  49.  
  50.     button.appendTo(bbcodes);
  51.  
  52.     if (document.location.pathname.split('/')[1] === 'topic') {
  53.         $('.text-color').filter(function () {
  54.             return CRYPTO_REGEXP.test($(this).attr('style'));
  55.         }).each(function () {
  56.             let encoded = $(this).attr('style').match(CRYPTO_REGEXP)[1].replace(new RegExp(EQUAL_SUBSTITUTOR, 'g'), '=');
  57.             console.log(encoded);
  58.             let msg = atob(encoded);
  59.             $.post('https://avenoel.org/previsualisation', {content: `Message Avepremium: <spoiler>${msg}</spoiler>`}).done(res => {
  60.                     $(this).html(res.content);
  61.             });
  62.         });
  63.     }
  64. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement