Skip to content

Instantly share code, notes, and snippets.

@anekos
Created February 14, 2010 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anekos/303963 to your computer and use it in GitHub Desktop.
Save anekos/303963 to your computer and use it in GitHub Desktop.
(function () {
let convertString = function (str, charset) {
let sis = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
sis.setData(str, str.length);
let cis = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
cis.init(sis, charset, 1024, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
let data = '', str = {};
while (cis.readString(1024, str) != 0)
data += str.value;
return data;
}
let convertURL =
function (url, charset)
convertString(url.replace(/%../g, function (m) String.fromCharCode('0x' + m.slice(1))), charset);
autocommands.add(
'VimperatorEnter',
/.*/,
function ()
plugins.libly.$U.around(
util,
'losslessDecodeURI',
function (next, [url])
(url.match && url.match(/^http/)
? next(convertURL(url, config.browser.docShell.QueryInterface(Ci.nsIDocCharset).charset))
: url)
)
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment