- mapkey
- vmapkey
- imapkey
- map
- unmap
- unmapAllExcept
- imap
- iunmap
- cmap
- vmap
- vunmap
- aceVimMap
- addVimMapKey
- addSearchAlias
- removeSearchAlias
- searchSelectedWith
- Clipboard.read
- Clipboard.write
- Hints.setNumeric
- Hints.setCharacters
- Hints.click
- Hints.create
- Hints.dispatchMouseClick
- Hints.style
- Normal.passThrough
- Normal.scroll
- Normal.feedkeys
- Normal.jumpVIMark
- Visual.style
- Front.showEditor
- Front.openOmnibar
- Front.registerInlineQuery
- getBrowserName
- Front.showBanner
- Front.showPopup
- isElementPartiallyInViewport
- getClickableElements
- tabOpenLink
- insertJS
- RUNTIME
Create a shortcut in normal mode to execute your own action.
keysstring the key sequence for the shortcut.annotationstring a help message to describe the action, which will displayed in help opened by?.jscodefunction a Javascript function to be bound. If the function needs an argument, next pressed key will be fed to the function.optionsobjectdomain: regex, a Javascript regex pattern to identify the domains that this mapping works, for example,/github\.com/isays that this mapping works only for github.com,repeatIgnore: boolean, whether this action can be repeated by dot command. (optional, defaultnull)
mapkey("<Space>", "pause/resume on youtube", function() {
var btn = document.querySelector("button.ytp-ad-overlay-close-button") || document.querySelector("button.ytp-ad-skip-button") || document.querySelector('ytd-watch-flexy button.ytp-play-button');
btn.click();
}, {domain: /youtube.com/i});- See: mapkey
Create a shortcut in visual mode to execute your own action.
keysstring the key sequence for the shortcut.annotationstring a help message to describe the action, which will displayed in help opened by?.jscodefunction a Javascript function to be bound. If the function needs an argument, next pressed key will be fed to the function.optionsobjectdomain: regex, a Javascript regex pattern to identify the domains that this mapping works, for example,/github\.com/isays that this mapping works only for github.com,repeatIgnore: boolean, whether this action can be repeated by dot command. (optional, defaultnull)
- See: mapkey
Create a shortcut in insert mode to execute your own action.
keysstring the key sequence for the shortcut.annotationstring a help message to describe the action, which will displayed in help opened by?.jscodefunction a Javascript function to be bound. If the function needs an argument, next pressed key will be fed to the function.optionsobjectdomain: regex, a Javascript regex pattern to identify the domains that this mapping works, for example,/github\.com/isays that this mapping works only for github.com,repeatIgnore: boolean, whether this action can be repeated by dot command. (optional, defaultnull)
Map a key sequence to another in normal mode.
new_keystrokestring a key sequence to replaceold_keystrokestring a key sequence to be replaceddomainregex a Javascript regex pattern to identify the domains that this mapping works. (optional, defaultnull)new_annotationstring use it instead of the annotation from old_keystroke if provided. (optional, defaultnull)
map(';d', '<Ctrl-Alt-d>');Unmap a key sequence in normal mode.
keystrokestring a key sequence to be removed.domainregex a Javascript regex pattern to identify the domains that this mapping will be removed. (optional, defaultnull)
unmap("<<", /youtube.com/);Unmap all keybindings except those specified.
keystrokesarray the keybindings you want to keep.domainregex a Javascript regex pattern to identify the domains that this mapping will be removed. (optional, defaultnull)
unmapAllExcept(['E','R','T'], /google.com|twitter.com/);- See: map
Map a key sequence to another in insert mode.
new_keystrokestring a key sequence to replaceold_keystrokestring a key sequence to be replaceddomainregex a Javascript regex pattern to identify the domains that this mapping works. (optional, defaultnull)new_annotationstring use it instead of the annotation from old_keystroke if provided. (optional, defaultnull)
- See: unmap
Unmap a key sequence in insert mode.
keystrokestring a key sequence to be removed.domainregex a Javascript regex pattern to identify the domains that this mapping will be removed. (optional, defaultnull)
- See: map
Map a key sequence to another in omnibar.
new_keystrokestring a key sequence to replaceold_keystrokestring a key sequence to be replaceddomainregex a Javascript regex pattern to identify the domains that this mapping works. (optional, defaultnull)new_annotationstring use it instead of the annotation from old_keystroke if provided. (optional, defaultnull)
- See: map
Map a key sequence to another in visual mode.
new_keystrokestring a key sequence to replaceold_keystrokestring a key sequence to be replaceddomainregex a Javascript regex pattern to identify the domains that this mapping works. (optional, defaultnull)new_annotationstring use it instead of the annotation from old_keystroke if provided. (optional, defaultnull)
- See: unmap
Unmap a key sequence in visual mode.
keystrokestring a key sequence to be removed.domainregex a Javascript regex pattern to identify the domains that this mapping will be removed. (optional, defaultnull)
Map the key sequence lhs to rhs for mode ctx in ACE editor.
lhsstring a key sequence to replacerhsstring a key sequence to be replacedctxstring a mode such asinsert,normal.
aceVimMap('J', ':bn', 'normal');Add map key in ACE editor.
objectsobject multiple objects to define key map in ACE, see more from ace/keyboard/vim.js
addVimMapKey(
{
keys: 'n',
type: 'motion',
motion: 'moveByCharacters',
motionArgs: {
forward: false
}
},
{
keys: 'e',
type: 'motion',
motion: 'moveByLines',
motionArgs: {
forward: true,
linewise: true
}
}
);Add a search engine alias into Omnibar.
aliasstring the key to trigger this search engine, one or several chars, used as search alias, when you input the string and pressspacein omnibar, the search engine will be triggered.promptstring a caption to be placed in front of the omnibar.search_urlstring the URL of the search engine, for example,https://www.s.com/search.html?query=, if there are extra parameters for the search engine, you can use it ashttps://www.s.com/search.html?query={0}&type=csorhttps://www.s.com/search.html?type=cs&query=(since order of URL parameters usually does not matter).search_leader_keystring<search_leader_key><alias>in normal mode will search selected text with this search engine directly without opening the omnibar, for examplesd. (optional, defaults)suggestion_urlstring the URL to fetch suggestions in omnibar when this search engine is triggered. (optional, defaultnull)callback_to_parse_suggestionfunction a function to parse the response fromsuggestion_urland return a list of strings as suggestions. Receives two arguments:response, the first argument, is an object containing a propertytextwhich holds the text of the response; andrequest, the second argument, is an object containing the propertiesquerywhich is the text of the query andurlwhich is the formatted URL for the request. (optional, defaultnull)only_this_site_keystring<search_leader_key><only_this_site_key><alias>in normal mode will search selected text within current site with this search engine directly without opening the omnibar, for examplesod. (optional, defaulto)optionsobjectfavicon_urlURL for favicon for this search engine,skipMapsiftruedisable creating key mappings for this search engine (optional, defaultnull)
addSearchAlias('d', 'duckduckgo', 'https://duckduckgo.com/?q=', 's', 'https://duckduckgo.com/ac/?q=', function(response) {
var res = JSON.parse(response.text);
return res.map(function(r){
return r.phrase;
});
});Remove a search engine alias from Omnibar.
aliasstring the alias of the search engine to be removed.search_leader_keystring<search_leader_key><alias>in normal mode will search selected text with this search engine directly without opening the omnibar, for examplesd. (optional, defaults)only_this_site_keystring<search_leader_key><only_this_site_key><alias>in normal mode will search selected text within current site with this search engine directly without opening the omnibar, for examplesod. (optional, defaulto)
removeSearchAlias('d');Search selected with.
sestring a search engine's search URLonlyThisSiteboolean whether to search only within current site, need support from the provided search engine. (optional, defaultfalse)interactiveboolean whether to search in interactive mode, in case that you need some small modification on the selected content. (optional, defaultfalse)aliasstring only used with interactive mode, in such case the url fromseis ignored, SurfingKeys will construct search URL from the alias registered byaddSearchAlias. (optional, default"")
searchSelectedWith('https://translate.google.com/?hl=en#auto/en/');Read from clipboard.
onReadyfunction a callback function to handle text read from clipboard.
Clipboard.read(function(response) {
console.log(response.data);
});Write text to clipboard.
textstring the text to be written to clipboard.
Clipboard.write(window.location.href);Use digits as hint label, with it set you could type text to filter links, this API is to replace original setting like Hints.numericHints = true;.
Hints.setNumeric();Set characters for generating hints, this API is to replace original setting like Hints.characters = "asdgqwertzxcvb";.
charactersstring the characters for generating hints.
Hints.setCharacters("asdgqwertzxcvb");Click element or create hints for elements to click.
linksstring or array of HTMLElement, click on it if there is only one in the array orforceparameter is true, otherwise hints will be generated for them. Iflinksis a string, it will be used as css selector forgetClickableElements.forceboolean force to click the first input element whether there are more than one elements inlinksor not. (optional, defaultfalse)
mapkey('zz', 'Hide replies', function() {
Hints.click(document.querySelectorAll("#less-replies:not([hidden])"), true);
});- See: Hints.dispatchMouseClick
Create hints for elements to click.
cssSelectorstring or array of HTMLElement, iflinksis a string, it will be used as css selector.onHintKeyfunction a callback function on hint keys pressed.attrsobjectactive: whether to activate the new tab when a link is opened,tabbed: whether to open a link in a new tab,multipleHits: whether to stay in hints mode after one hint is triggered. (optional, defaultnull)
mapkey('yA', '#7Copy a link URL to the clipboard', function() {
Hints.create('*[href]', function(element) {
Clipboard.write('[' + element.innerText + '](' + element.href + ')');
});
});Returns boolean whether any hint is created for target elements.
- See: Hints.create
The default onHintKey implementation.
elementHTMLElement the element for which the pressed hint is targeted.
mapkey('q', 'click on images', function() {
Hints.create("div.media_box img", Hints.dispatchMouseClick);
}, {domain: /weibo.com/i});Set styles for hints.
cssstring styles for hints.modestring sub mode for hints, usetextfor hints mode to enter visual mode. (optional, defaultnull)
Hints.style('border: solid 3px #552a48; color:#efe1eb; background: none; background-color: #552a48;');
Hints.style("div{border: solid 3px #707070; color:#efe1eb; background: none; background-color: #707070;} div.begin{color:red;}", "text");Enter PassThrough mode.
timeoutnumber? how many milliseconds to linger in PassThrough mode, to ignore it will stay in PassThrough mode until an Escape key is pressed.
Scroll within current target.
typestring down | up | pageDown | fullPageDown | pageUp | fullPageUp | top | bottom | left | right | leftmost | rightmost | byRatio
Feed keys into Normal mode.
keysstring the keys to be fed into Normal mode.
Jump to a vim-like mark.
markstring a vim-like mark.
Set styles for visual mode.
Visual.style('marks', 'background-color: #89a1e2;');
Visual.style('cursor', 'background-color: #9065b7;');Launch the vim editor.
elementHTMLElement the target element which the vim editor is launched for, this parameter can also be a string, which will be used as default content in vim editor.onWritefunction a callback function to be executed on written back from vim editor.typestring the type for the vim editor, which can beurl, if not provided, it will be tag name of the target element. (optional, defaultnull)useNeovimboolean the vim editor will be the embeded JS implementation, ifuseNeovimis true, neovim will be used through natvie messaging. (optional, defaultfalse)
mapkey(';U', '#4Edit current URL with vim editor, and reload', function() {
Front.showEditor(window.location.href, function(data) {
window.location.href = data;
}, 'url');
});Open the omnibar.
argsobjecttypethe sub type for the omnibar, which can beBookmarks,AddBookmark,History,URLs,RecentlyClosed,TabURLs,Tabs,Windows,VIMarks,SearchEngine,Commands,OmniQueryandUserURLs.
mapkey('ou', '#8Open AWS services', function() {
var services = Array.from(top.document.querySelectorAll('#awsc-services-container li[data-service-href]')).map(function(li) {
return {
title: li.querySelector("span.service-label").textContent,
url: li.getAttribute('data-service-href')
};
});
if (services.length === 0) {
services = Array.from(top.document.querySelectorAll('div[data-testid="awsc-nav-service-list"] li[data-testid]>a')).map(function(a) {
return {
title: a.innerText,
url: a.href
};
});
}
Front.openOmnibar({type: "UserURLs", extra: services});
}, {domain: /console.amazonaws|console.aws.amazon.com/i});- See: example.
Register an inline query.
argsobjecturl: string or function, the dictionary service url or a function to return the dictionary service url,parseResult: function, a function to parse result from dictionary service and return a HTML string to render explanation,headers: object[optional], in case your dictionary service needs authentication.
Get current browser name
Returns string "Chrome" | "Firefox" | "Safari"
Show message in banner.
msgstring the message to be displayed in banner.timeoutnumber milliseconds after which the banner will disappear. (optional, default1600)
Front.showBanner(window.location.href);Show message in popup.
msgstring the message to be displayed in popup.
Front.showPopup(window.location.href);Check whether an element is in viewport.
elElement the element to be checked.ignoreSizeboolean whether to ignore size of the element, otherwise the element must be with size 4*4. (optional, defaultfalse)
Returns boolean
Get all clickable elements. SurfingKeys has its own logic to identify clickable elements, such as a HTMLAnchorElement or elements with cursor as pointer. This function provides two parameters to identify those clickable elements that SurfingKeys failed to identify.
selectorStringstring extra css selector of those clickable elements.patternregex a regular expression that matches text of the clickable elements.
var elms = getClickableElements("[rel=link]", /click this/);Returns array array of clickable elements.
Open links in new tabs.
strstring links to be opened, the links should be split by\nif there are more than one.simultaneousnessnumber how many tabs will be opened simultaneously, the rest will be queued and opened later whenever a tab is closed. (optional, default5)
mapkey("<Space>", "pause/resume on youtube", function() {
var btn = document.querySelector("button.ytp-ad-overlay-close-button") || document.querySelector("button.ytp-ad-skip-button") || document.querySelector('ytd-watch-flexy button.ytp-play-button');
btn.click();
}, {domain: /youtube.com/i});Insert javascript code into main world context.
code(function | string) a javascript function to be executed in main world context, or an URL of js file.onloadfunction a callback function after requested code executed.
Call background action with args, the callback will be executed with response from background.
actionstring a background action to be called.argsobject the parameters to be passed to the background action.callbackfunction a function to be executed with the result from the background action.
RUNTIME('getTabs', {queryInfo: {currentWindow: true}}, response => {
console.log(response);
});