Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name E621 Swimmer
- // @description Navigate e621's pools with arrow keys
- // @include http*://e621.net/post/show/*
- // ==/UserScript==
- window.onLoad = checkForPool();
- function checkForPool()
- {
- var tags = document.getElementsByTagName('h6');
- for (var i = 0; i < tags.length; ++i)
- {
- if (tags[i].innerHTML === 'Pool')
- {
- var parent = tags[i].parentNode;
- var innerTags = parent.getElementsByTagName('a');
- document.addEventListener('keydown', function (e)
- {
- //Uncomment any of these if some modifier key is wanted,
- // uncommenting all three will require all three to be pressed
- //if (!e.shiftKey){ return; }
- //if (!e.ctrlKey){ return; }
- //if (!e.metaKey){ return; }
- //Return if target is a text field (where text navigation takes precedence)
- var t = e.srcElement || e.target;
- var tagName = t.tagName.toUpperCase();
- var type = '';
- if (t.type){
- type = t.type.toUpperCase();
- }
- if ((tagName === 'INPUT' &&
- (
- type === 'TEXT' ||
- type === 'PASSWORD' ||
- type === 'SEARCH' ||
- type === 'EMAIL' ||
- type === 'NUMBER' ||
- type === 'DATE' )
- ) ||
- tagName === 'TEXTAREA')
- {
- return;
- }
- var p = innerTags[1];
- var n = p;
- if (innerTags.length > 2){
- n = innerTags[2];
- }
- if (e.keyCode === 37 && p.innerHTML.substring(0, 8) == "<<")
- {
- window.location=p.href;
- }
- else if (e.keyCode === 39 && n.innerHTML.substring(n.innerHTML.length-8, n.innerHTML.length) == ">>")
- {
- window.location=n.href;
- }
- }, false);
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment