Advertisement
Eshkation-

text highlight

Feb 3rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         bbcode_hg
  3. // @namespace    -
  4. // @version      0.1
  5. // @description  Highlight para as mensagens do chat do jogo
  6. // @author       Eshkation
  7. // @match        *atelier801.com/*
  8. // ==/UserScript==
  9.  
  10. $(document).ready(function(){
  11.     $('#outils_message_reponse > .groupe-boutons-barre-outils:last-child').prepend(`
  12.         <button type="button" class="btn btn-reduit btn-success" id="highlight-text">
  13.             Highlight
  14.         </button>
  15.     `);
  16.  
  17.     $(document).on('click', '#highlight-text', function(){
  18.         var text_final = '[font=Verdana][size=11][color=#92AFCF]';
  19.         var text_lines = window.getSelection().toString();
  20.         text_lines = text_lines.split('\n');
  21.         for (i = 0; i < text_lines.length; i++) {
  22.             var line = text_lines[i];
  23.             line = line.replace(/\[([A-Za-z0-9\_\+]{3,20})\]/, '[[color=#317FBA]$1[/color]]');
  24.             text_final += line+'\n';
  25.         }
  26.         text_final += '[/color][/size][/font]';
  27.         var textarea = $(window.getSelection().anchorNode.parentNode).find('textarea');
  28.         $(textarea).val(text_final);
  29.         console.log(text_final);
  30.     });
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement