Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name bbcode_hg
- // @namespace -
- // @version 0.1
- // @description Highlight para as mensagens do chat do jogo
- // @author Eshkation
- // @match *atelier801.com/*
- // ==/UserScript==
- $(document).ready(function(){
- $('#outils_message_reponse > .groupe-boutons-barre-outils:last-child').prepend(`
- <button type="button" class="btn btn-reduit btn-success" id="highlight-text">
- Highlight
- </button>
- `);
- $(document).on('click', '#highlight-text', function(){
- var text_final = '[font=Verdana][size=11][color=#9BA0A4]';
- var text_lines = window.getSelection().toString();
- var p_input = prompt('Destacar quais nicks de jogadores?', 'Nick1, Nick2');
- if (p_input == null || p_input == '') {
- return '';
- }
- else {
- var highlight_nicks = p_input.replace(/ /g,'').split(',');
- text_lines = text_lines.split('\n');
- for (i = 0; i < text_lines.length; i++) {
- var line = text_lines[i];
- var line_nick;
- line = line.replace(/\[([A-Za-z0-9\_\+]{3,20})\]/, function(_, nick){
- line_nick = nick;
- if (highlight_nicks.includes(nick)){
- return '[[color=#B4BA31]'+nick+'[/color]]';
- }
- else {
- return '[[color=#92A9BA]'+nick+'[/color]]';
- }
- });
- if (highlight_nicks.includes(line_nick)){
- line = '[color=#CFCD93]'+line+'[/color]';
- }
- text_final += line+'\n';
- }
- text_final += '[/color][/size][/font]';
- var textarea = $(window.getSelection().anchorNode.parentNode).find('textarea');
- $(textarea).val(text_final);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement