Skip to content

Instantly share code, notes, and snippets.

@ulissesalmeida
Created January 15, 2016 23:53
Show Gist options
  • Save ulissesalmeida/5a4f2cd1d1cb7d5a2745 to your computer and use it in GitHub Desktop.
Save ulissesalmeida/5a4f2cd1d1cb7d5a2745 to your computer and use it in GitHub Desktop.
Overload Navigator - Navigate on galleries with arrow keys
// ==UserScript==
// @name Overload Navigator
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Navigate on galleries with arrow keys
// @author ulisseslameida
// @match http://overloadr.com.br/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
(function() {
console.log("Overload Navigator v 0.1");
var $ = jQuery;
var slides = $('.slides').last();
var right = 39;
var prev = 37;
console.log("Slides gallery found: " + slides.length);
var activeSlide = function(slides) {
return slides.find('.flex-active-slide').last();
};
var navigate = function(slide) {
if (slide.length > 0) {
slide.click();
}
};
var nextSlide = function(event) {
if(event.keyCode == right) {
navigate(activeSlide(slides).next());
}
};
var prevSlide = function(event) {
if(event.keyCode == prev) {
navigate(activeSlide(slides).prev());
}
};
if(slides.length > 0) {
$('body').keyup(nextSlide);
$('body').keyup(prevSlide);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment