boorufixer

fetch & replace small booru thumbnails with larger hires source.

اعتبارا من 30-07-2017. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         boorufixer
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  fetch & replace small booru thumbnails with larger hires source.
// @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 sheet = document.createElement('style');
    sheet.innerHTML = ".thumb img { max-width: 100%; max-height: 100%; }  span.thumb { height: 400px; width: 400px; }";
    document.body.appendChild(sheet);

    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){

            var adiv = document.createElement('div');
            $(adiv).html(r);

            var hires_img_url = $(adiv).find('#image')[0].src;
            // console.log(hires_img_url);
            var the_image = $(v).find('a img')[0];
            the_image.src = hires_img_url; // replacement!
            $(the_image).css("width", '');
        };
        // 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);