Skip to content

Instantly share code, notes, and snippets.

@Dramacydal
Created April 7, 2020 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dramacydal/ff83b191e1d087081c468ae7858a5c40 to your computer and use it in GitHub Desktop.
Save Dramacydal/ff83b191e1d087081c468ae7858a5c40 to your computer and use it in GitHub Desktop.
thiswaifudoesnotexist
// ==UserScript==
// @name waifu
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.thiswaifudoesnotexist.net/
// @grant none
// @run-at document-end
// @require http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==
(function() {
$('button').closest('p').prepend('<button id="previous" value="Previous">PREVIOUS</button>');
let prev = $('button#previous');
console.log(prev);
var currId = null;
var lastIds = [];
function refresh_content_custom(customId) {
currId = customId;
id = customId;
new_waifu(id);
inject_snippet(id);
}
prev.click(function(e){
console.log(lastIds);
if (lastIds.length <= 0) {
return;
}
let lastId = lastIds.splice(-1)[0];
if (interval) {
clearInterval(interval);
refresh_content_custom(lastId);
interval = setInterval(refresh_content, refreshDelay);
} else {
refresh_content_custom(lastId);
}
});
let refreshButton = $($('button')[1]);
currId = id;
refreshButton.click(function(e) {
if (currId !== null) {
lastIds.push(currId);
}
//console.log(id)
currId = id;
});
/*
if (interval) {
clearInterval(interval);
refresh_content();
interval = setInterval(refresh_content, refreshDelay);
} else {
refresh_content();
}
id = Math.floor(Math.random() * totalImages);
new_waifu(id);
inject_snippet(id);
*/
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment