HF AutoSignature

Insert automatically your signature when you click on "Post Reply"

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        HF AutoSignature
// @namespace   HF AutoSignature
// @description Insert automatically your signature when you click on "Post Reply"
// @include     http://www.hackforums.net/*
// @include     http://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
// ==/UserScript==

var signature = GM_getValue('autoSignature', '');
var enabled = GM_getValue('autoSignatureEnabled', false);


function saveAutoSigSettings() {
	GM_setValue('autoSignature', document.getElementById('signature').value);
	if (document.getElementById('checkEnable').checked) { GM_setValue('autoSignatureEnabled', true); } else { GM_setValue('autoSignatureEnabled', false); }
	document.getElementById('submitAutoSig').innerHTML = "Changes saved successfully. To save again, you can click here.";
}
exportFunction(saveAutoSigSettings, unsafeWindow, {defineAs: "saveAutoSigSettings"});

if (document.URL.indexOf("showthread.php") >= 0) {
	$('#quick_reply_submit').on("click", function () {
		if (enabled) {
		  prevMessage = document.getElementById("message").value;
		  document.getElementById("message").value = prevMessage + '\n\n' + signature;
		}
	})
}

if (document.URL.indexOf("usercp.php") >= 0) {
  var settingsAutoSigHTML = "<table class='tborder' cellspacing='1' cellpadding='4' border='0'><tbody><tr><td class='thead' colspan='2'><strong> HF AutoSignature : Settings <button class='button' onclick='saveAutoSigSettings()'><span id='submitAutoSig'>Save</span></button></strong></td></tr><tr><td class='trow1'>Your signature : <input type='text' id='signature' value='"+signature+"'></input> <input id='checkEnable' type='checkbox'><label for='checkEnable'>Enable the Auto Signature ?</label></input> </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(settingsAutoSigHTML);
  if (enabled) { document.getElementById('checkEnable').setAttribute('checked', 'checked'); }
 }