HF Replacer

Replace a word by another

18.06.2015 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        HF Replacer
// @namespace   HF
// @description Replace a word by another
// @include     http://www.hackforums.net/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @version     1
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_deleteValue
// ==/UserScript==

var customText = GM_getValue('customText', '');
var send = GM_getValue('send', 'false');

function saveSettings() {
  if (document.getElementById('charCount').innerHTML >= 25) { 
    GM_setValue('customText', document.getElementById('valueTextReplacer').value)
    if (document.getElementById('checkSendAuto').checked) {
      GM_setValue('send', true);
    } else {
      GM_setValue('send', false);
    }
    document.getElementById('submitReplacer').innerHTML = "Changes saved";
  } else { alert('You don\'t have more than 25 characters. Please correct and submit again.'); }
}
exportFunction(saveSettings, unsafeWindow, {defineAs: "saveSettings"});

function insertText() {
  var prevMessage = document.getElementById("message").value;
  document.getElementById('message').value = prevMessage + customText;
  if (send) { document.getElementById('quick_reply_submit').click() }
}
exportFunction(insertText, unsafeWindow, {defineAs: "insertText"});

if (document.URL.indexOf("usercp.php") >= 0) {
  var settingsHTML = "<table class='tborder' cellspacing='1' cellpadding='4' border='0'><tbody><tr><td class='thead' colspan='2'><strong> HF Replacer : Settings</strong></td></tr><tr><td class='trow1'>Text : <input type='text' id='valueTextReplacer' value='" + customText + "'></input>(<span id='charCount'></span>/25) <input id='checkSendAuto' type='checkbox'><label for='checkSendAuto'>Send automatically the message ?</label></input> <button class='button' onclick='saveSettings()'><span id='submitReplacer'>Save</span></button></td></tr></table><br />";
  $('.quick_keys > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > br:nth-child(2)').after(settingsHTML);
  document.getElementById('charCount').innerHTML = $('#valueTextReplacer').val().length;
  $('#valueTextReplacer').on('keyup', function() {
    document.getElementById('charCount').innerHTML = $('#valueTextReplacer').val().length;
  });
  if (send) { document.getElementById('checkSendAuto').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 button = document.createElement('a');
  button.appendChild(document.createTextNode('Custom Text'));
  button.setAttribute('title', 'Custom Text');
  button.setAttribute('onClick', 'insertText()');
  button.setAttribute('class', 'button');
  bLocation[0].appendChild(button);
}