Danbooru Post Link Rating

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

2015/10/04のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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.0

// ==/UserScript==


var links = document.getElementsByTagName("a");

for(var l=0; l<links.length; l++) {
	if(links[l].href.indexOf("/posts/") > -1)
	{
		var postID = links[l].href.substring(links[l].href.lastIndexOf("/posts/") + 7);
	}
	else if(links[l].href.indexOf("/post/show/") > -1)
	{
		var postID = links[l].href.endsWith("/") ? links[l].href.substring(links[l].href.lastIndexOf("/post/show/") + 11,links[l].href.lastIndexOf("/")) : links[l].href.substring(links[l].href.lastIndexOf("/post/show/") + 11);
	}
	else 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();
}