8chan-MD5

Display image md5s

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         8chan-MD5
// @version      0.3.1
// @description  Display image md5s
// @author       Anonymous
// @match        *://8ch.net/*
// @grant        none
// @namespace    https://greasyfork.org/users/18941
// ==/UserScript==

String.prototype.hexEncode = function() {
	var result = "";
	for (var i = 0; i < this.length; i++) { result += this.charCodeAt(i).toString(16); }
	return result;
};

(function(window, $) {
	var md5 = {
		init: function() {
			// apply md5 to all posts now.
			md5.append(document.body);

			// add md5 to any posts that may be added.
			this.observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { var newNodes = mutation.addedNodes; if (newNodes !== null) { $(newNodes).each(function() { md5.append(this); }); } }); });
			this.observer.observe($('.thread')[0], {attributes: true, childList: true, characterData: true});
		},

		append: function(root) {
			$(root).find('.files .file').each(function() {
				var md5 = window.atob($(this).find('.post-image').attr('data-md5')).hexEncode();
				$(this).find('.fileinfo .unimportant').append(" <a href='javascript:md5.toggle(\"" + md5 + "\");'>#</a><br/><span id='md5_" + md5 + "' class='hidden'>MD5: " + md5 + "</span>");
			});
		},
		
		toggle: function(md5) {
		  $('#md5_' + md5).toggleClass('hidden');
		}
	};

	md5.init();
	window.md5 = md5;
})(window, jQuery);