Skip to content

Instantly share code, notes, and snippets.

@prestancedesign
Last active August 31, 2021 15:34
Embed
What would you like to do?
// Afficher les boites de liens à gauche
settings.hintAlign = "left";
// Se déplacer avec <C-j> et <C-k> dans Omnibox
cmap('<Ctrl-j>', '<Tab>');
cmap('<Ctrl-k>', '<Shift-Tab>');
// Différentes règles afin de retrouver quelques comportements de base de Vimium
map('u', 'e');
mapkey('p', "Open the clipboard's URL in the current tab", function() {
Front.getContentFromClipboard(function(response) {
window.location.href = response.data;
});
});
mapkey('oH', '#8Open opened URL in current tab', function() {
Front.openOmnibar({type: "URLs", extra: "getTabURLs"});
});
map('F', 'af');
map('`', '\'');
map('H', 'S');
map('L', 'D');
map('gt', 'R');
map('gT', 'E');
map('K', 'R');
map('J', 'E');
aceVimMap('fd', '<Esc>', 'insert');
// Exclusion pour le moteur de recherche Duckduckgo, Youtube, etc
if (window.location.origin === "https://duckduckgo.com" || window.location.origin === "https://www.youtube.com") {
unmap('h');
unmap('j');
unmap('k');
unmap('l');
}
// Exclusion pour Gmail
if (window.location.origin === "https://mail.google.com") {
unmap('?');
unmap('j');
unmap('k');
unmap('n');
unmap('p');
unmap('x');
unmap('e');
unmap('E');
unmap('D');
unmap('r');
unmap('c');
unmap('g');
unmap('i');
unmap('l');
unmap('s');
unmap('#');
unmap('u');
unmap('l');
unmap('d');
unmap('/');
unmap('a');
}
// Add wikipédia search
addSearchAliasX('w', 'wikipédia', 'https://en.wikipedia.org/wiki/Special:Search?search=', 's', 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=', function(response) {
var res = eval(response.text);
return res[1];
});
function openLinkInCurrentTab(url) {
RUNTIME("openLink", {
tab: {
tabbed: false
},
url: url
});
}
// Switch from DuckDuckGo to Google and vice versa
if (window.location.origin === "https://duckduckgo.com") {
mapkey('sz', 'Duckduckgo search on Google', function() {
openLinkInCurrentTab(constructSearchURL('https://google.fr/search?q=', encodeURIComponent(document.getElementById('search_form_input').value)));
});
} else if (window.location.origin === "https://www.google.fr" || window.location.origin === "https://www.google.com") {
mapkey('sz', 'Google search on Duckduckgo', function() {
openLinkInCurrentTab(constructSearchURL('https://duckduckgo.com/?q=', encodeURIComponent(document.getElementsByTagName('input').q.value)));
});
}
// Add Duckduckgo Omnitab search
mapkey('od', 'Open Search with alias d', function() {
Front.openOmnibar({type: "SearchEngine", extra: "d"});
});
// Add selector to allow clicking on Google translate buttons
settings.clickableSelector = "*.jfk-button, *.goog-flat-menu-button";
mapkey('gl', 'Switch on local dev and online Medisafe website', function() {
if (window.location.origin === "https://www.medisafe.fr") {
tabOpenLink("http://medisafe.ms" + window.location.pathname + window.location.search);
} else if(window.location.origin === "http://medisafe.ms") {
tabOpenLink("https://www.medisafe.fr" + window.location.pathname + window.location.search);
}
});
settings.nextLinkRegex = /((>>|next|Suivant|Suite)+)/i;
settings.prevLinkRegex = /((<<|prev(ious)?|Précédent|Préc.)+)/i;
function generateFormKey(form) {
return (form.method || "get") + "::" + new URL(form.action).pathname;
}
mapkey('yf', '#7Copy form data in JSON on current page', function() {
var fd = {};
document.querySelectorAll('form').forEach(function(form) {
fd[generateFormKey(form)] = getFormData(form, "json");
});
Clipboard.write(JSON.stringify(fd, null, 4));
});
mapkey(';pf', '#7Fill form with data from yf', function() {
Hints.create('form', function(element, event) {
var formKey = generateFormKey(element);
Clipboard.read(function(response) {
var forms = JSON.parse(response.data.trim());
if (forms.hasOwnProperty(formKey)) {
var fd = forms[formKey];
element.querySelectorAll('input').forEach(function(ip) {
if (fd.hasOwnProperty(ip.name) && typeof(fd[ip.name]) !== "object") {
ip.value = fd[ip.name];
}
});
} else {
Front.showBanner("No form data found for your selection from clipboard.");
}
});
});
});
settings.modeAfterYank = "Normal";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment