// ==UserScript==
// @name xfaqs Rotating Sigs
// @version 1.0.0
// @author Kraust
// @namespace Kraust
// @description Rotating Sigs
// @include http://*.gamefaqs.com/*
// @grant none
// @require //cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js
// @downloadURL https://update.greasyfork.cloud/scripts/3870/xfaqs%20Rotating%20Sigs.user.js
// @updateURL https://update.greasyfork.cloud/scripts/3870/xfaqs%20Rotating%20Sigs.meta.js
// ==/UserScript==
/*
This is a mirror of the rotating sig code used in xfaqs
created by Kraust/Judgmenl
If there are any problems please let me know. I only partially looked this over.
I would not use it with xfaqs as xfaqs already has it present.
*/
/*
This uses localStorage to keep Sigs in JSON data
*/
if( localStorage.getItem("sigList") != null ) {
var sigList = JSON.parse(localStorage.getItem("sigList"));
} else {
var sigList =
{
"signatures": [
]
};
localStorage.setItem("sigList", JSON.stringify(sigList));
}
/*
There are two callback functions needed for the dynamic click handlers
*/
function sigClickCallback(i) {
return function() {
var sigText = $("#signature-" + i).val();
var sigLines = (sigText.match(/\n/g)||[]).length;
var sigCharacters = sigText.length + sigLines;
if((sigLines <= 1) && (sigCharacters <= 160)) {
$(".btn").attr("disabled", "disabled");
sigList.signatures.splice((i-1), 1);
var boardNameArray = $.csv.toArray($("#boards-" + i).val());
var accountNameArray = $.csv.toArray($("#accounts-" + i).val());
sigList.signatures.push(
{
"boards": boardNameArray,
"accounts": accountNameArray,
"signature": $("#signature-" + i).val()
});
localStorage.setItem("sigList", JSON.stringify(sigList));
document.location = "/boards/user.php?settings=1#tabs-5";
location.reload(true);
} else {
alert("Signature is too long. " + sigLines + " breaks and " + sigCharacters + " characters.");
}
}
}
function sigDeleteCallback(i) {
return function() {
$("#sigTable-" + i).remove();
$(".btn").attr("disabled", "disabled");
sigList.signatures.splice((i-1), 1);
localStorage.setItem("sigList", JSON.stringify(sigList));
document.location = "/boards/user.php?settings=1#tabs-5";
location.reload(true);
}
}
/*
This renders the options page
*/
var sigBody = "
1 line break and 160 characters allowed. Just like with regular sigs. If you want a signature to apply to all boards or accounts leave the field blank. Multiple boards and accounts are separated by commas.