// ==UserScript== // @name HF insertText() // @namespace HF // @description Quicly insert text into your post and send it automatically (or nah) // @include http://www.hackforums.net/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js // @version 1.1 // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @downloadURL none // ==/UserScript== var customText = []; var sendFor = []; for (i=1; i<6; i++) { customText[i] = GM_getValue('customText['+i+']', ''); sendFor[i] = GM_getValue('sendFor['+i+']', 'false'); } function saveSettings() { for (nb=1;nb<6;nb++) { if (document.getElementById('valueTextReplacer' + nb).value.length >= 25) { GM_setValue('customText[' + nb + ']', document.getElementById('valueTextReplacer' + nb).value) if (document.getElementById('checkSendAuto' + nb).checked) { GM_setValue('sendFor[' + nb + ']', true); } else { GM_setValue('sendFor[' + nb + ']', false); } document.getElementById('submitReplacer').innerHTML = "Changes saved"; } else { alert('You don\'t have more than 25 characters in the field #' + nb + '. Please correct and submit again.'); } } } exportFunction(saveSettings, unsafeWindow, {defineAs: "saveSettings"}); function insertText(nb) { var prevMessage = document.getElementById("message").value; document.getElementById('message').value = prevMessage + customText[nb]; if (sendFor[nb]) { document.getElementById('quick_reply_submit').click() } } exportFunction(insertText, unsafeWindow, {defineAs: "insertText"}); if (document.URL.indexOf("usercp.php") >= 0) { var settingsHTML = "
HF Replacer : Settings
Text 1:
Text 2:
Text 3:
Text 4:
Text 5:

"; $('.quick_keys > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > br:nth-child(2)').after(settingsHTML); if (sendFor[1]) { document.getElementById('checkSendAuto1').setAttribute('checked', 'checked'); } if (sendFor[2]) { document.getElementById('checkSendAuto2').setAttribute('checked', 'checked'); } if (sendFor[3]) { document.getElementById('checkSendAuto3').setAttribute('checked', 'checked'); } if (sendFor[4]) { document.getElementById('checkSendAuto4').setAttribute('checked', 'checked'); } if (sendFor[5]) { document.getElementById('checkSendAuto5').setAttribute('checked', 'checked'); } } if (document.URL.indexOf("showthread.php") >= 0) { var bLocation = document.querySelectorAll('#quickreply_e > tr:nth-child(2) > td:nth-child(1)'); var br = document.createElement('br'); bLocation[0].appendChild(br); var button = document.createElement('a'); button.appendChild(document.createTextNode(customText[1].substr(0,10))); button.setAttribute('title', 'Custom Text'); button.setAttribute('onClick', 'insertText(1)'); button.setAttribute('class', 'button'); bLocation[0].appendChild(button); var button = document.createElement('a'); button.appendChild(document.createTextNode(customText[2].substr(0,10))); button.setAttribute('title', 'Custom Text'); button.setAttribute('onClick', 'insertText(2)'); button.setAttribute('class', 'button'); bLocation[0].appendChild(button); var button = document.createElement('a'); button.appendChild(document.createTextNode(customText[3].substr(0,10))); button.setAttribute('title', 'Custom Text'); button.setAttribute('onClick', 'insertText(3)'); button.setAttribute('class', 'button'); bLocation[0].appendChild(button); var button = document.createElement('a'); button.appendChild(document.createTextNode(customText[4].substr(0,10))); button.setAttribute('title', 'Custom Text'); button.setAttribute('onClick', 'insertText(4)'); button.setAttribute('class', 'button'); bLocation[0].appendChild(button); var button = document.createElement('a'); button.appendChild(document.createTextNode(customText[5].substr(0,10))); button.setAttribute('title', 'Custom Text'); button.setAttribute('onClick', 'insertText(5)'); button.setAttribute('class', 'button'); bLocation[0].appendChild(button); }