// ==UserScript== // @name HF insertText() // @namespace HF // @description Quicly insert text into your post and send it automatically (or nah) // @include *hackforums.net/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js // @version 1.2.1 // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @downloadURL https://update.greasyfork.icu/scripts/10480/HF%20insertText%28%29.user.js // @updateURL https://update.greasyfork.icu/scripts/10480/HF%20insertText%28%29.meta.js // ==/UserScript== var customText = []; var customTextTitle = []; var sendFor = []; for (i=1; i<6; i++) { customText[i] = GM_getValue('customText['+i+']', ''); sendFor[i] = GM_getValue('sendFor['+i+']', 'false'); customTextTitle[i] = GM_getValue('customTextTitle['+i+']', 'Title ' + i); } function saveSettings() { for (i=1;i<6;i++) { if (document.getElementById('customText'+i).value.length >= 25 || document.getElementById('customText' + i).value.length === 0) { GM_setValue('customText['+i+']', document.getElementById('customText'+i).value); GM_setValue('customTextTitle['+i+']', document.getElementById('customTextTitle'+i).value); if (document.getElementById('checkSendAuto' + i).checked) { GM_setValue('sendFor['+i+']', true); } else { GM_setValue('sendFor['+i+']', false); } document.getElementById('submitReplacer').innerHTML = "Changes saved successfully. To save again, you can click here."; } else { alert('You don\'t have more than 25 characters in the field #'+i+'. Please correct and submit again.'); } } } exportFunction(saveSettings, unsafeWindow, {defineAs: "saveSettings"}); function insertText(i) { var prevMessage = document.getElementById("message").value; document.getElementById('message').value = prevMessage + customText[i]; if (sendFor[i]) { document.getElementById('quick_reply_submit').click() } } exportFunction(insertText, unsafeWindow, {defineAs: "insertText"}); if (document.URL.indexOf("usercp.php") >= 0) { var settingsHTML = "
HF Replacer : Settings
Title 1 : Text 1:
Title 2 : Text 2:
Title 3 : Text 3:
Title 4 : Text 4:
Title 5 : 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); for (i=1;i<6;i++) { if (sendFor[i]) { document.getElementById('checkSendAuto' + i).setAttribute('checked', 'checked'); } } } if (document.URL.indexOf("showthread.php") >= 0) { var buttonsHTML = "
"; if (customTextTitle[1] !== "") { buttonsHTML += ""+customTextTitle[1]+" "; } if (customTextTitle[2] !== "") { buttonsHTML += ""+customTextTitle[2]+" "; } if (customTextTitle[3] !== "") { buttonsHTML += ""+customTextTitle[3]+" "; } if (customTextTitle[4] !== "") { buttonsHTML += ""+customTextTitle[4]+" "; } if (customTextTitle[5] !== "") { buttonsHTML += ""+customTextTitle[5]+" "; } buttonsHTML += "
"; $('input.button:nth-child(2)').after(buttonsHTML); }