NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name whatcd gazelle navigation buttons on requests page
// @include /https?://www\.empornium\.(me|sx)/requests\.php\?action=view&id=.*/
// @version 1
// @require http://code.jquery.com/jquery-2.1.1.js
// @grant none
// ==/UserScript==
"use strict";
this.$ = this.jQuery = jQuery.noConflict(true);
function AddNavigationButtons() {
var self = this;
this.request_id = null;
this.create_arrow = function (request_id, title, img_src) {
var $arrow = jQuery('<span><a><img></img></a></span>');
jQuery('a', $arrow).prop({
'title': title,
'href': self.create_request_url(request_id)
});
jQuery('img', $arrow).prop('src', img_src);
return $arrow;
};
this.create_prev_arrow = function (request_id) {
var $arrow = self.create_arrow(
request_id,
'goto previous torrent',
'static/styles/modern/images/arrow_left.png'
);
$arrow.css('float', 'left');
return $arrow;
};
this.create_next_arrow = function (request_id) {
var $arrow = self.create_arrow(
request_id,
'goto next torrent',
'static/styles/modern/images/arrow_right.png'
);
$arrow.css('float', 'right');
return $arrow;
};
this.get_current_request_id = function () {
return parseInt(window.location.href.match(/id=(\d+)/)[1]);
};
this.create_request_url = function (request_id) {
return window.location.href.replace(/id=(\d+)/, 'id=' + request_id);
};
this.add_navigation_buttons = function () {
var $h2 = jQuery('#content h2');
$h2.prepend(self.create_prev_arrow(self.request_id - 1));
$h2.append(self.create_next_arrow(self.request_id + 1));
}
this.init = function () {
self.request_id = self.get_current_request_id();
self.add_navigation_buttons();
};
this.init();
}
jQuery(document).ready(function() {
new AddNavigationButtons();
});