pentadactylrc: google translate

This commit is contained in:
Gabriel Ebner 2014-07-16 21:08:20 +02:00
parent b11b7fee43
commit 4f1de6eadc

@ -12,4 +12,24 @@ set passkeys+=reader.gebner.org:u<C-Up><C-Down><Up><Down>,fr
silent qmark b javascript:if(top['bookmarklet-url@wallabag.org']){top['bookmarklet-url@wallabag.org'];}else{(function(){var%20url%20=%20location.href%20||%20url;window.open('https://wllbg.gebner.org/?action=add&url='%20+%20btoa(url),'_self');})();void(0);}
"" google translate
command trans -js <<EOF
let getParameterByName = function(url, name) {
let name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
let regexS = '[\\?&]' + name + '=([^&#]*)';
let regex = new RegExp(regexS);
let results = regex.exec(url);
if (results == null)
return '';
else
return decodeURIComponent(results[1].replace(/\+/g, ' '));
};
if (buffer.URL.spec.startsWith('http://translate.google.com/')) {
dactyl.open(getParameterByName(buffer.URL.spec, 'u'));
} else {
dactyl.open('http://translate.google.com/translate?hl=en&sl=auto&tl=en&u=' + encodeURIComponent(buffer.URL.spec));
}
EOF
nmap -builtin ,t :trans<CR>
" vim: set ft=pentadactyl: