// ==UserScript== // @namespace http://mrob.com/time/scripts-beta // @name multiquote for OTT // @description Changes quote buttons behaviour to quote multiple messages // @author Pikrass and mrob27 // @version 8233.07 // @downloadURL http://mrob.com/time/scripts-beta/multiquote.user.js.txt // @resource quote_waiting imgs/quote_waiting.png // @resource quote_ok imgs/quote_ok.png // @include http://forums.xkcd.com/viewtopic.php* // @include http://fora.xkcd.com/viewtopic.php* // @include http://echochamber.me/viewtopic.php* // @include http://forums.xkcd.com/posting.php* // @include http://fora.xkcd.com/posting.php* // @include http://echochamber.me/posting.php* // ==/UserScript== /* REVISION HISTORY np1674.00 Version by Pikrass that was used as the basis of this version. np5330.00 Include the original post text in the editable area, so you can edit out the parts you don't want right away. np8227.61 Add checkboxes at bottom (one currently unused), add "quoter's name in blue" option np8233.07 Second option enables the "mrob27 enhancement" */ multiquote = { /* Load all our saved quotes/replies, so they're available in case the user wants to edit a previously-saved block of text. */ init: function() { this.quotes = JSON.parse(GM_getValue('quotes', '{}')); }, // Set a checkbox to be on or off setChkVal: function(chk, val) { if (val == 0) { chk.checked=false; } else { chk.checked=true; } }, /* opt_action will set or clear an option. */ opt_action: function(chk, optobj, nam) { // If the option was just initialized, it will now become set. // This makes sense becuse if they've just installed the script // and click on the checkbox, they want to set the checkbox. if (optobj.val == 0) { optobj.val = 1; } else { optobj.val = 0; } this.setChkVal(chk, optobj.val); chk.disabled = false; /* Save the user's work in a way that will persist across page loads. * see http://wiki.greasespot.net/GM_setValue */ GM_setValue(nam, JSON.stringify(optobj.val)); }, make_checkbox: function(nam, title, optobj, pdiv) { // Make the checkbox for 'reveal light text' var chk = document.createElement('input'); chk.type = 'checkbox'; chk.value = 'temp-' + nam; chk.id = nam; var lbl = document.createElement('label') lbl.htmlFor = nam; var lab_text = document.createTextNode(title); lbl.appendChild(lab_text); this.setChkVal(chk, optobj.val); chk.addEventListener('click', this.opt_action.bind(this, chk, optobj, nam)); pdiv.appendChild(chk); pdiv.appendChild(lbl); }, /* create_checkboxen will add a checkbox that changes an option */ create_checkboxen: function() { var container = document.createElement('div'); var preDiv = document.createElement('div'); preDiv.style.marginTop = '1px'; preDiv.style.fontSize = '1.0em'; preDiv.style.fontWeight = 'bold'; preDiv.style.color = '#0B7'; var optstitle = document.createTextNode("Multiquote by Pikrass, enhanced by Mrob27:"); preDiv.appendChild(optstitle); var opts_div = document.createElement('div'); opts_div.style.textAlign = 'left'; // Make the checkbox for opts_div.appendChild(document.createTextNode("  ")); this.make_checkbox('o_hil_blue', 'Highlight Quoted Name in Blue', this.o_hil_blue, opts_div); // Make the checkbox for opts_div.appendChild(document.createTextNode(" ")); this.make_checkbox('o_incl_quoted', 'Include Quoted Text In Edit Area', this.o_incl_quoted, opts_div); container.appendChild(preDiv); container.appendChild(opts_div); return(container); }, // Initialize options init_options: function() { // %%% 20171117: Editing the options is disabled for now, because // GM_xxxValue is useless. I can shim the GM_ functions with // localStorage, see newpix_converter to see how. if (0) { this.o_hil_blue = { val: JSON.parse(GM_getValue('o_hil_blue', '0')) }; if (typeof this.o_hil_blue == 'undefined') { this.o_hil_blue = { val: "0" }; this.o_hil_blue.val = JSON.parse(GM_getValue('o_hil_blue', '0')); }; this.o_incl_quoted = { val: JSON.parse(GM_getValue('o_incl_quoted', '0')) }; if (typeof this.o_incl_quoted == 'undefined') { this.o_incl_quoted = { val: "0" }; this.o_incl_quoted.val = JSON.parse(GM_getValue('o_incl_quoted', '0')); }; } else { this.o_hil_blue = { val: 1 }; this.o_incl_quoted = { val: 1 }; } }, // Create the checkboxes. add_option_controls: function() { var footer = document.getElementById("page-footer"); var ft_par = footer.parentNode; ft_par.insertBefore(this.create_checkboxen(), footer); }, convert: function() { this.init(); // loads saved quote data this.init_options(); this.add_option_controls(); var buttons = document.getElementsByClassName('quote-icon'); var i; for(i=0 ; i