DeviantBlocker

DeviantArt gallery - block images from selected artists

当前为 2015-12-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name DeviantBlocker
// @namespace brandrock.co.za
// @description DeviantArt gallery - block images from selected artists
// @include http://www.deviantart.com/
// @include http://www.deviantart.com/?*
// @include http://browse.deviantart.com/*
// @include http://www.deviantart.com/browse/*
// @include https://www.deviantart.com/
// @include https://www.deviantart.com/?*
// @include https://browse.deviantart.com/*
// @include https://www.deviantart.com/browse/*
// @version 1.2
// @grant GM_log
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==

// This work is licensed under the Creative Commons Attribution 2.0 Generic License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/.

var blacklist = GM_getValue('DAGbl', '|');
var thumbs = document.getElementsByTagName('IMG');

for(var i = thumbs.length; i--;) {
	var img = thumbs[i];
	if (img.getAttribute('data-src')){
		var div = img.parentNode;
		while (!(div.tagName == 'DIV' && div.getAttribute('userid')>'')) {
			div = div.parentNode;
		}
		var username = div.getAttribute('username');
		var userid = div.getAttribute('userid');
		var elem = document.createElement('button');
		elem.type = 'button';
		elem.userid = userid;
		img.userid = userid;
		elem.title = 'Click to hide/show images from this artist';
		elem.innerHTML = username;
		var useridD = '|' + userid + '|'
		if (blacklist.indexOf(useridD) > -1){
			img.style.visibility = 'hidden';
			elem.addEventListener('click', function(){
				artistShow(this);
			});
		} else {
			elem.addEventListener('click', function(){
				artistHide(this);
			});
		}
		catSpan = div.querySelector(".category");
		catSpan.parentNode.insertBefore(elem, catSpan);
	}
}

function artistHide(button) {
	blacklist = blacklist + button.userid + '|';
	GM_setValue('DAGbl', blacklist);
	for(var i = thumbs.length; i--;) {
		var img = thumbs[i];
		if(img.userid == button.userid){
			img.style.visibility = 'hidden';
		}
	}
}
function artistShow(button) {
	blacklist = blacklist.replace(button.userid + '|', '');
	GM_setValue('DAGbl', blacklist);
	for(var i = thumbs.length; i--;) {
		var img = thumbs[i];
		if(img.userid == button.userid){
			img.style.visibility = 'visible';
		}
	}
}