Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name FastPrevNext.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// ==/UserScript==
(function(){
var INSERT_POSITION = document.getElementById('star-button');
if (!INSERT_POSITION) return;
var BUTTONS = [
{
onclick : '(' + function(){
if (!/^(.*?)(\d+)($|\D+)$/.test(gBrowser.currentURI.spec)) return;
var num = RegExp.$2;
if (num == 0){
var z = 0;
}else{
for (var z = 0; num[z] == '0'; z++);
}
for (var i = 0, num = parseInt(num, 10) + 1; i < z; i++, num = '0' + num);
loadURI(RegExp.$1 + num + RegExp.$3);
}.toString() + ')()',
style : 'padding: 0px 2px;',
src : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB6ElEQVQ4jZWRXVMSYRTHn/GqV5sMBvZ52d2buqo7v4JNaTKBrZmIEDgxmWFSTDLc+HF2mukDaC8EbLzEgkCSJKIiZl3UZ/h3sdrUDDFwZn535/875zwPIT1KGtsYlcY2Rnv1/LccN9evSxPvf0q33/1yjL+5MVDYfid1VXKlvlNXGtSVgnPyww/b+NtrfYXppCFLU0abej6CegxQtwHqzoDeTXect5Jq78la0smmc012Pw82nQfTcmBaDvReFnQqC8ljtGwug3YNM3fhCp8tbjFvEWy2CPbgk8VMweJESrXstlNL2/8Jj3jzw9xfNrm/DD5fBp8vgftK4HMl8DkTzGta0lPxTKFyaSJz+eRm85wIVjMiVIMIVsGDVfCHFfBABTywCe7fxB+x71RsgnnNvM1lXCSErA2RQPLM34hQ7ZVYqEGEahChKkSwChaovB7x5oftWvKCw7d+nmjZs4SsDXV9DxGu6yJchwjXIR5tWSx81vv6RkIIEYsNXX7SgLy4bfH4C0S4PoBguanLkSbkyA7kpzuQl75CLDX6F8jRPV2JtqCstKCs7EJ5tgux3BxAEGvrSuwASuwAyot9KM/3IUf3+heoq4e6Gu9AXT20eNmGHGsPsEHiOKImvulq4sgifqTL8U6kW+9vk6sFzJJ3Qv4AAAAASUVORK5CYII=",
},
{
onclick : '(' + function(){
if (!/^(.*?)(\d+)($|\D+)$/.test(gBrowser.currentURI.spec)) return;
var num = RegExp.$2;
if (num == '0') return;
for (var z = 0; num[z] == '0'; z++);
for (var i = 0, num = parseInt(num, 10) - 1; i < z; i++, num = '0' + num);
loadURI(RegExp.$1 + num + RegExp.$3);
}.toString() + ')()',
style : 'padding: 0px 2px;',
src : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB5UlEQVQ4jZWRy1NScRiGz7jq3thYcn5Xp1XtaumuHWUxmoZaDAygICheTzLRyj/nTDPNsG4YEUVAuchBUS4iWLSphX/C24KwmiEH3pln97zv4vsUpUNM5i+aao6EVXMkrD6PhNWRzbDpRUTr5HaMaWRTV19Gob7agmrZgmqJgVhietcDxBLTyeg2yOg2yNgOyOsdkLF4DwPjcZ2M74JM7IJMJEDeJECsyR4GrEmdTiZBJ1OgUynQ6T2QqVQPA9P7On27D/ou3cKWAbWlux+gtrTO7FkwexbMkQNz5EAduf8NbPQpz6LX/oY6Dz4xZx7MlQdzGWBuA2wm//meLXXnvjV6a9Bu3GTWxHVF2ehTiCVzgzoP4syVB3Mb4G4DfKYAPlsAnz0E9xyCe47AvUfgc8UWvmOwueLegDt+W1EURem3Zu5yTyF7KXrbYksW/mOI+ZMWCyXw+ZIh/IX+fw/nzQxwX7Eo/H9EsVCCCJRbLFYglioQS5XSoM940PEaPFAiIlCuXcrLVYjlKuTK6W9qdbpYZVd+wLRyMiRWT5tyrQa5dgapnUFqdYj39e9itfKwqzcSrfxIrtd/yGADMngOGTz/KYONx12V2xlarz+Roa8X8uO3C/mh8bSncjsy1ByWoebwVc4vJ8QIDO2aJxYAAAAASUVORK5CYII=",
},
];
BUTTONS.forEach(function(elem){
var button = document.createElement('image');
for (var n in elem){
button.setAttribute(n, elem[n]);
}
INSERT_POSITION.parentNode.insertBefore(button, INSERT_POSITION);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.