Last active
May 17, 2019 06:07
-
-
Save aodiquan/1bfdd364496e68c24b661a2e2139272d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 链接:https://gitee.com/moyihai/codes/virzeh8mdy3n1kq5w2ucg97/raw?blob_name=gistfile1.txt | |
// create map | |
mapkey('zT', '#8Open a URL', function(){ | |
Front.openOmnibar({type: "URLs", extra: "getAllSites"}); | |
}); | |
mapkey('<Space>', '#1Click on an Image or a button', function(){ | |
Hints.create("img, button", Hints.dispatchMouseClick); | |
}); | |
Front.registerInlineQuery({ | |
url: "http://fanyi.youdao.com/openapi.do?keyfrom=YouDaoCV&key=659600698&type=data&doctype=json&version=1.2&q=", | |
parseResult: function(res) { | |
try { | |
res = JSON.parse(res.text); | |
var exp = ''; | |
var pronunciations = []; | |
if (res.basic && res.basic.explains) { | |
for (var reg in res.basic.explains) { | |
pronunciations.push(`<div style='color:black;'>[${reg}] ${res.basic.explains[reg]}</div>`); | |
} | |
} | |
if (res.web) { | |
pronunciations.push(`<br><div style='color:black;'>网络释义</div>`); | |
for (var reg in res.web) { | |
var val = (res.web[reg].value || []).join('\n'); | |
pronunciations.push(`<div style='color:black;'>[${res.web[reg].key}] ${val}</div>`); | |
} | |
} | |
exp = `${pronunciations.join("")}`; | |
return exp; | |
} catch (e) { | |
return ""; | |
} | |
} | |
}); | |
mapkey('zh', '#8Open URL from history', function(){ | |
Front.openOmnibar({type: "History"}); | |
}); | |
mapkey('F', '#1Open a link in non-active new tab', function(){ | |
Hints.create("", Hints.dispatchMouseClick, {tabbed: true, active: false}); | |
}); | |
mapkey('r', '#4Reload the page', function(){ | |
RUNTIME("reloadTab", { nocache: true }); | |
}); | |
mapkey('J', '#3Go one tab right', function(){ | |
RUNTIME("nextTab"); | |
}); | |
mapkey('K', '#3Go one tab right', function(){ | |
RUNTIME("previousTab"); | |
}); | |
mapkey('zr', '#13show failed web requests of current page', function() { | |
runtime.command({ | |
action: 'getTabErrors' | |
}, function(response) { | |
if (response.tabError && response.tabError.length) { | |
var errors = response.tabError.map(function(e) { | |
var url = new URL(e.url); | |
return "<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>".format(e.error, e.type, url.host); | |
}); | |
Front.showPopup("<table style='width:100%'>{0}</table>".format(errors.join(''))); | |
} else { | |
Front.showPopup("No errors from webRequest."); | |
} | |
}); | |
}); | |
mapkey('mm', '#8Bookmark current page to selected folder', function() { | |
var page = { | |
url: window.location.href, | |
title: document.title | |
}; | |
Front.openOmnibar(({type: "AddBookmark", extra: page})); | |
}); | |
mapkey('mM', '#8Open URL from vim-like marks', function() { | |
Front.openOmnibar({type: "VIMarks"}); | |
}); | |
mapkey('N', '#3Open Chrome newtab', function() { | |
tabOpenLink("chrome://newtab/"); | |
}); | |
// new map | |
map('H', 'S'); | |
map('L', 'D'); | |
map('u', 'e'); | |
map('zt', 'T'); | |
map('ze', 'ox'); | |
map('zb', 'b'); | |
map('zh', 'oh'); | |
map('yl', 'ya'); | |
map('gc', 'gb'); | |
map("'", "<Ctrl-'>"); | |
// remove map | |
unmap('e'); | |
unmap('<Ctrl-i>'); | |
unmap('cp'); | |
unmap('spa'); | |
unmap('spb'); | |
unmap('spd'); | |
unmap('sps'); | |
unmap('spc'); | |
unmap('spi'); | |
unmap('sfr'); | |
unmap('zi'); | |
unmap('zo'); | |
unmap('zQ'); | |
unmap('ZZ'); | |
unmap('ZR'); | |
unmap('af'); | |
unmap('cf'); | |
unmap('<Ctrl-h>'); | |
unmap('<Ctrl-j>'); | |
unmap('ya'); | |
unmap('<Ctrl-i>'); | |
unmap('E'); | |
unmap('<Alt-p>'); | |
unmap('<Alt-m>'); | |
unmap('S'); | |
unmap('D'); | |
unmap('go'); | |
unmap('gb'); | |
unmap('ox'); | |
unmap('b'); | |
// unmap('W'); | |
unmap('on'); | |
// unmap("<Ctrl-'>"); | |
// unmap('m'); | |
unmap('cc'); | |
// set theme | |
// settings.theme = ` | |
// .sk_theme { | |
// background: #000; | |
// color: #fff; | |
// } | |
// .sk_theme tbody { | |
// color: #000; | |
// } | |
// .sk_theme input { | |
// color: #317ef3; | |
// } | |
// .sk_theme .url { | |
// color: #38f; | |
// } | |
// .sk_theme .annotation { | |
// color: #38f; | |
// } | |
// .sk_theme .focused { | |
// background: #aaa; | |
// }`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment