HF AutoSignature

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

当前为 2015-08-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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'); }
 }