Danbooru Post Link Rating

Finds links to posts on Danbooru and appends that post's rating to the end

Stan na 08-11-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name          Danbooru Post Link Rating
// @namespace     DoomTay
// @description   Finds links to posts on Danbooru and appends that post's rating to the end
// @include       http://danbooru.donmai.us/*
// @include       https://danbooru.donmai.us/*
// @version       1.0.5

// ==/UserScript==

var links = document.links;

for(var l=0; l<links.length; l++)
{
	if(links[l].firstChild.nodeName == "IMG") continue;
	if(document.getElementById("pool-nav") && document.getElementById("pool-nav").contains(links[l])) continue;
	if(links[l].href.indexOf("/posts/") > -1 && /\/posts\/(\d+)/.exec(links[l].href) != null)
	{
		var postID = /\/posts\/(\d+)/.exec(links[l].href)[1];
	}
	else if(links[l].href.indexOf("/post/show/") > -1 && /\/post\/show\/(\d+)(?:\/)?/.exec(links[l].href) != null)
	{
		var postID = /\/post\/show\/(\d+)(?:\/)?/.exec(links[l].href)[1];
	}
	else continue;
	if(window.location.href.indexOf(postID) > -1) continue;
	if(isNaN(postID)) continue;
	appendRating(links[l],postID);
}

function appendRating(link,id)
{
	var post = new XMLHttpRequest();
	var url = '/posts/' + id + '.json';
	post.onload = function () {
		var rating = JSON.parse(post.responseText).rating;
		var ratingReading = document.createElement("span");
		ratingReading.innerHTML = " (rating: " + rating + ")";
		link.parentNode.insertBefore(ratingReading, link.nextSibling);
	}
	post.open("GET", url, true);
	post.send();
}