there's jquery everywhere ¯\_(ツ)_/¯
当前为
// ==UserScript==
// @name boorufixer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description there's jquery everywhere ¯\_(ツ)_/¯
// @author justrunmyscripts
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @match *://*.booru.org/*
// @grant none
// @run-at document-end
// @noframes
// ==/UserScript==
// @grant GM_xmlhttpRequest
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) // 4 = done
callback(xmlHttp.responseText);
};
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
}
(function($) {
// 'use strict';
var thumbnails = $('.thumb');
$.each(thumbnails ,function(k, v){
var hires_img_url_haystack_url = $(v).children()[0].href;
var extract_hires_img_url_cb = function(r){
//console.log(r);
var adiv = document.createElement('div');
$(adiv).html(r);
var hires_img_url = $(adiv).find('#image')[0].src;
console.log(hires_img_url);
};
// TODO add some 1s + random sleep here to 'rate limit'
// how: add to a list, that is consumed through timeouts
// in timeoutFunc, we call httpGetAsync(...);
httpGetAsync(hires_img_url_haystack_url, extract_hires_img_url_cb);
});
}).bind(this)(jQuery);