Dynasty Link Thingifier

Adds post links and quote stuff to Dynasty forums

2015-08-22 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Dynasty Link Thingifier
// @namespace   Alice Cheshire
// @include     http://dynasty-scans.com/forum/topics
// @version     1.2.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();
tmpurl = pageurl;
postids = [];
postcount = 0;
pageurl = pageurl.replace(/(#.+)/, "");
$('.forum_post').each(function() {
  postids.push(this.id);
});
$('.time').each(function(i, obj) {
  postcount++;
});
if (tmpurl.match(/http:\/\/dynasty-scans.com\/forum\/posts\?user_id=\d+/)) {
  tmpurl = tmpurl.replace(/\d+/, "");
}
for (i = 0; i < postcount; i++){
  id = postids[i].toString();
  if(tmpurl !== "http://dynasty-scans.com/forum/posts?user_id=") {
     $(".time").eq(i).replaceWith("<div class=\"span5 time\"><a href=\"" + pageurl + "#" + id + "\">" + $(".time").eq(i).text() + "</a></div>");
  }
}
$('a').click(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();
}