Adds post links and quote stuff to Dynasty forums
当前为
// ==UserScript==
// @name Dynasty Link Thingifier
// @namespace Alice Cheshire
// @include http://dynasty-scans.com/*
// @version 1
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @description Adds post links and quote stuff to Dynasty forums
// @author
// @run-at document-end
// ==/UserScript==
pageurl = document.location.toString();
postids = [];
postcount = 0;
pageurl = pageurl.replace(/(#.+)/, "");
$('.forum_post').each(function() {
postids.push(this.id);
});
$('.time').each(function(i, obj) {
postcount++;
});
for (i = 0; i < postcount; i++){
id = postids[i].toString();
$(".time").eq(i).replaceWith("<div class=\"span5 time\"><a href=\"" + pageurl + "#" + id + "\">" + $(".time").eq(i).text() + "</a></div>");
}
$('a').hover(function(e) {
if ($(e.target).text() == "Quote") {
postid = $(e.target).parents();
postid = postid[4];
postid = $(postid).attr('id');
postid = "#" + postid;
postid = postid.toString();
document.cookie = "quote=" + pageurl + postid + ";path=/";
quotename = $(postid).find(".user").text();
quotename = $.trim(quotename);
document.cookie = "username=" + quotename + ";path=/";
} else {
console.log("No match!");
}
});
quoting = pageurl.replace(/http:\/\/dynasty-scans.com\/forum\//, "");
quoting = quoting.replace(/\?.+/, "");
if (quoting === "posts/new") {
post = getCookie("quote");
username = getCookie("username");
console.log(post + "\n" + username);
quote = "[" + username + "](" + post + ")";
message = "\n" + document.getElementById('forum_post_message').value;
document.getElementById('forum_post_message').value = quote + message;
}
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}