Skip to content

Instantly share code, notes, and snippets.

@42RK
Last active July 18, 2017 10:54
Show Gist options
  • Save 42RK/d13afc8c91c2e1548483c344c7c84151 to your computer and use it in GitHub Desktop.
Save 42RK/d13afc8c91c2e1548483c344c7c84151 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Derpibooru Quick Downloader
// @version 1.0
// @description display the DS (download with a short name) button over the thumbnail in search results
// @author Scriptki77y
// @include https://derpibooru.org/*
// @include http://derpibooru.org/*
// @run-at document-end
// ==/UserScript==
var parser = new DOMParser()
elements = document.querySelectorAll('#imagelist_container .media-box__header.media-box__header--link-row')
elements3 = document.querySelectorAll('#imagelist_container .thumb')
for(let i = 0; i < elements.length ; ++i)
{
url = JSON.parse(elements3[i].dataset.uris).large
elements[i].appendChild(generate_button(url.replace('img', 'img/download').replace('/large', '')))
}
function generate_button(url) {
let node = parser.parseFromString(`
<a rel="nofollow"
title="Download this image at full res with a short filename"
href="${url}">
<i class="fa fa-download"></i> DS</a>
`, "text/html").body.childNodes[0];
return node;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment