Gelbooru fullscreen image viewer

Auto loads original version of any picture on Gelbooru website

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Gelbooru fullscreen image viewer
// @description    Auto loads original version of any picture on Gelbooru website
// @exclude        /^https?://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}#$/
// @include        /^https?://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}$/
// @include        /^https?://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}\&pool_id=\d{1,99}$/
// @require        https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// @author         iceman94
// @copyright      2015+, iceman94
// @version        0.02
// @grant          none
// @namespace https://greasyfork.org/users/148290
// ==/UserScript==

//https://gelbooru.com/index.php?page=post&s=view&id=3646928
//http://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}$

//=======================================================================================================
// Cross-browsers load function
// Tests in this order :
// -support for jQuery API
// |-uses $(window).load method if available
// |-uses $(window).ready method if available
// -support for DOMContentLoaded event (compatible only with the following browsers :
// Chrome >= 0.2; Firefox >= 1.0; IE >= 9.0; Opera >= 9.0; Safari >= 3.1)
// -support for document.attachEvent
// -uses setTimeout w/ 5000ms delay
//=======================================================================================================

function XBLoad (func, verbose)
{
    verbose = verbose || false;

    if (window.jQuery)
    {
        if ($(window).load)
        {
            if (verbose == true) { console.log('Javascript loaded using $(window).load method'); };
            return $(window).load(function() { func(); });
        }
        else if ($(window).ready)
        {
            if (verbose == true) { console.log('Javascript loaded using $(window).ready method'); };
            return $(window).ready(function() { func(); });
        };        
    }
    else if (document.addEventListener)
    {
        if (verbose == true) { console.log('Javascript loaded using document.addEventListener method'); };
        document.addEventListener('DOMContentLoaded', function(event)
        {
            return func();
        });
    }
    else if (document.attachEvent)
    {
        if (verbose == true) { console.log('Javascript loaded using document.attachEvent method'); };
        document.attachEvent('load', function()
        {
            return func();
        });
    }
    else
    {
        if (verbose == true) { console.log('Javascript loaded using setTimeout method'); };
        return setTimeout(function() { func(); }, 5000);
    };
};


//=======================================================================================================
// Setting up functions
//=======================================================================================================

// Loads original (high resolution) version of any picture if available
function loadOriginal ()
{
	var coll = document.getElementsByTagName('a');
	var collL = coll.length;
	for (var i=0; i<collL; i++)
	{
		if (coll[i] && coll[i].textContent == 'Original image')
		{
			editLocation();
			window.location = coll[i].href;
		}
	}
}
// function loadOriginal ()
// {
	// if (document.getElementById('image') && document.getElementById('image').src)
	// {
		// $('body').load( document.getElementById('image').src);
	// }
// }

// Appends pound ('#') symbol to actual URI to avoid endless redirecting
function editLocation ()
{
	window.location.replace(window.location.href + "#");
}


//=======================================================================================================
// Showtime !
//=======================================================================================================

XBLoad(loadOriginal());