Display image md5s
当前为
// ==UserScript==
// @name 8chan-MD5
// @version 0.2.1
// @description Display image md5s
// @author Anonymous
// @match *://8ch.net/*
// @grant none
// @namespace https://greasyfork.org/users/18941
// ==/UserScript==
String.prototype.hexEncode = function(){
var hex, i;
var result = "";
for (i=0; i<this.length; i++) {
hex = this.charCodeAt(i).toString(16);
result += hex;
}
return result
}
function applyMD5(root) {
$(root).find('.files .file').each(function() {
$(this).find('.fileinfo .unimportant').append("<br/>MD5: " + window.atob($(this).find('.post-image').attr('data-md5')).hexEncode());
});
}
applyMD5(document.body); // apply md5 to all posts now.
var observer = new MutationObserver(function(mutations) { // add md5 to any posts that may be added.
mutations.forEach(function(mutation) {
var newNodes = mutation.addedNodes;
if (newNodes !== null) {
var $nodes = $(newNodes);
$nodes.each(function() {
applyMD5(this);
});
}
});
});
observer.observe($('.thread')[0], {attributes: true, childList: true, characterData: true});