Gelbooru Show Original Resolution on Resized Notice

Shows the dimensions of the original image together with the prompt to show it.

As of 2020-11-25. See the latest version.

// ==UserScript==
// @name         Gelbooru Show Original Resolution on Resized Notice
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Shows the dimensions of the original image together with the prompt to show it.
// @author       Xerodusk
// @homepage     https://greasyfork.org/en/users/460331-xerodusk
// @include      https://gelbooru.com/index.php*page=post&s=view*
// @grant        none
// @icon         https://gelbooru.com/favicon.png
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
    'use strict';

    // Get the resized status alert if exists, otherwise nothing to do
    const resizedNotice = document.getElementById('resized_notice');
    if (!resizedNotice || resizedNotice.classList.contains('alert-info-deleted')) {
        return;
    }

    // Get functionally-buttons-but-presented-as-links
    let buttons = resizedNotice.getElementsByTagName('a');
    if (buttons.length != 3) {
        return;
    }
    buttons = Array.from(buttons).map(button => button.cloneNode(true));

    // Clear current notice
    while (resizedNotice.firstChild) {
        resizedNotice.removeChild(resizedNotice.firstChild);
    }

    // Construct new notice with extra text inserted into the middle
    resizedNotice.appendChild(document.createTextNode('This image has been resized. Click '));
    resizedNotice.appendChild(buttons[0]);
    resizedNotice.appendChild(document.createTextNode(' to view the original ' + window.image.width + 'x' + window.image.height + ' image. '));
    resizedNotice.appendChild(buttons[1]);
    resizedNotice.appendChild(document.createTextNode(' | '));
    resizedNotice.appendChild(buttons[2]);
    resizedNotice.appendChild(document.createTextNode('.'));
})();