NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Booru Tweaks
// @namespace ProxyFiend.BooruTweaks
// @author ProxyFiend
// @homepage https://openuserjs.org/scripts/ProxyFiend/Booru_Tweaks
// @supportURL https://openuserjs.org/scripts/ProxyFiend/Booru_Tweaks/issues
// @copyright 2019, ProxyFiend (https://twitter.com/ProxyFiend)
// @license MPL-2.0
// @version 1.2
// @description Adds Ctrl + S support for a few different Booru websites.
// @include *://*.konachan.org/*
// @include *://konachan.com/post/show/*
// @include *://yande.re/post/show/*
// @updateURL https://openuserjs.org/meta/ProxyFiend/Booru_Tweaks.meta.js
// @downloadURL https://openuserjs.org/src/scripts/ProxyFiend/Booru_Tweaks.user.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @grant GM_download
// ==/UserScript==
(function() {
'use strict';
var downloadFlag = false;
var capitalizeFirstChar = function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
};
var initMoebooru = function() {
$("#highres").attr("data-href", $("#highres").attr("href")).attr("href", "#download");
$("#highres").click(function() {
if (downloadFlag === false) {
downloadFlag = true;
GM_download($("#highres").attr("data-href"), capitalizeFirstChar(m[1]) + " - " + m[2] + ".jpg");
}
});
$(window).bind('keydown', function (event) {
if (event.ctrlKey || event.metaKey) {
switch (String.fromCharCode(event.which).toLowerCase()) {
case 's':
event.preventDefault();
$("#highres")[0].click();
break;
}
}
});
};
const regex = /([^\/]*)\/post\/show\/(\d*)/g;
let m = regex.exec(window.location);
switch (m[1]) {
case "konachan.org":
initMoebooru();
break;
case "konachan.com":
initMoebooru();
break;
case "yande.re":
initMoebooru();
break;
}
})();