E621 helper v3.0 (2021.12)

Script to help navigating e621 (created in 2021.12)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name E621 helper v3.0 (2021.12)
// @namespace Violentmonkey Scripts
// @match https://e621.net/posts/*
// @grant none
// @description:en Script to help navigating e621 (created in 2021.12)
// @version 0.0.1.20191009221730
// @description Script to help navigating e621 (created in 2021.12)
// @license MIT 
// ==/UserScript==


var prev_pool = null;
var prev_search = null;

var next_pool = null;
var next_search = null;

var download = null;

var image = null;

function keyPress(kk){
  //Left Arrow
  if(kk == 37){
    if(prev_search){
      prev_search.click();
    }else if(prev_pool){
      prev_pool.click();
    }
  //Right Arrow
  } else if(kk == 39 || kk == 32){
    if(next_search){
      next_search.click();
    }
    else if(next_pool){
      next_pool.click(); 
    }
  //Numeric 1
  } else if(kk == 97 && prev_pool){
    prev_pool.click();
  //Numeric 3
  } else if(kk == 99 && next_pool){
     next_pool.click();
  //Enter
  } else if(kk == 13 && download){
    download.click();
  }
}

window.addEventListener("load", function(){
  image = document.getElementById("image");
  start();
});

function start(){
  window.addEventListener("keydown", function(e){
    e = e || window.event;
    if(e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 13 || e.keyCode == 96 || e.keyCode == 97 || e.keyCode == 99 || e.keyCode == 32){
      keyPress(e.keyCode);
    }
  });
  
  image.addEventListener("click", function(e){
    if(next_search){
      next_search.click();
    }
    else if(next_pool){
      next_pool.click(); 
    }
  });
  
  var search_nav = document.getElementsByClassName("search-seq-nav")[0];  
  var pool_nav = document.getElementsByClassName("pool-nav")[0];

  if(search_nav){
    prev_search = search_nav.children[0].children[0].children[0];
    next_search = search_nav.children[0].children[0].children[2];
  }
  else if(pool_nav){
    prev_pool = pool_nav.children[0].children[0].children[1];
    next_pool = pool_nav.children[0].children[0].children[3];
  }
  
  download = document.getElementById("image-download-link").children[0];
  
  sidebar = document.getElementsByClassName("sidebar")[0];
  img = document.getElementById("image");
  
  console.log("E621 helper loaded :)\r\n=================================\r\nKey layout:\r\n" + 
              "\tLeft arrow: Previous search result OR Previous image in pool.\r\n" + 
              "\tRight arrow: Next search result OR Next image in pool.\r\n" + 
              "\tSpace bar: Next search result OR Next image in pool.\r\n" + 
              "\tClicking the image: Next search result OR Next image in pool.\r\n" + 
              "\tNUM 1: Previous image in pool.*\r\n" + 
              "\tNum 3: Next image in pool.*\r\n" + 
              "\tEnter: Download image.\r\n\t\r\n" + 
              "\t*Even if there are other search results\r\n=================================\r\n" + 
              "\t\r\nHave fun~\r\n\t\t-WolfyD");
}