1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // Vimperator plugin: 'Ex Autocmd' // Last Change: 20-May-2008. Jan 2008 // License: Creative Commons // Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid // // extends autocmd for vimperator0.6.* // Ex Events: // TabSelect // TabLeave // CurrentPageLoad var recentTabURI = null; function tabSelect(e){ liberator.autocommands.trigger("TabLeave",recentTabURI ? recentTabURI : ""); liberator.autocommands.trigger/** * ==VimperatorPlugin== * @name incuri.js * @description increment the number in the URI * @description-ja URIに含まれる数字をインクリメント * @author hogelog * @version 0.03 * ==/VimperatorPlugin== * * COMMANDS: * :decdomain -> Decrement the number in the domain name * :decfragment -> Decrement the number in the fragment ID * :decpath -> Decrement the number in the path name * :decport -> Decrement the number in the port number * :decquery -> Decrement the number in the query string * :decuri -> Decrement the number in the URI * :incdomain -> Increment the number in the domain name * :incfragment -> Increment the number in the fragment ID * :incpath -> Increment the number in the path name * :incport -> Increment the number in the port number * :incquery -> Increment the number in the query string * :incuri -> Increment the number in the URI * */ (function() { var numreg = /^(.*\D|)(\d+)(\D*)$/; function numstr(num, len) { var str = String(num); while(str.length<len) { str = "0" + str; } return str; } function makeinc(f, p) function(args) { var l = window.content.location; var part = l[p]; if(p == "port" && part == "") { part = ({ "ftp:" : "21", "http:" : "80", "https:" : "443" })[l.protocol] || part; } if(numreg.test(part)) { arg = args[0]; let num = RegExp.$2; let quantity = !arg || isNaN(arg) ? 1 : parseInt(arg); let nextnum = numstr(f(parseInt(num, 10), quantity), num.length); let newpart = RegExp.$1 + nextnum + RegExp.$3; if(p == "href") { window.content.location.href = newpart; } else { window.content.location.href = [ "protocol", "//", "hostname", ":", "port", "pathname", "search", "hash" ].map(function(part) part.length > 2 ? p == part ? newpart : l[part] : part) .join(""); } } else { liberator.echoerr("Cannot find a number in the " + p + " <" + part + ">"); } }; [ ["uri", "href", "URI"], ["path", "pathname", "path name"], ["query", "search", "query string"], ["fragment", "hash", "fragment ID"], ["port", "port", "port number"], ["domain", "hostname", "domain name"] ].forEach(function(part) { var [suffix, prop, name] = part; [ ["In", 1], ["De", -1] ].forEach(function(direction) { var [prefix, dir] = direction; commands .add([prefix.toLowerCase() + "c" + suffix], prefix + "crement the number in the " + name + ".", makeinc(function(x, q) x + dir * q, prop), { argCount : "?" }); }); }); })(); // vim: set sw=4 ts=4 sts=4 et: