Skip to content

Instantly share code, notes, and snippets.

@chroju
Last active August 22, 2022 09:23
Show Gist options
  • Save chroju/9072d8bc5a65b124db61e2a22566e573 to your computer and use it in GitHub Desktop.
Save chroju/9072d8bc5a65b124db61e2a22566e573 to your computer and use it in GitHub Desktop.
Vimium and Shortkeys
[
{
"action": "javascript",
"code": "var asin = document.body.querySelector(\"input[name^='ASIN']\").value;\nlocation.href = 'https://booklog.jp/item/1/' + asin;",
"key": ", k",
"sites": "",
"sitesArray": [
""
]
},
{
"key": "k",
"action": "scrollup",
"sites": "",
"sitesArray": [
""
]
},
{
"action": "javascript",
"key": ", m",
"code": "let str = \"[\" + document.title.replace(/[\\[\\]]/g, \"\\\\$&\").replace(/\\\\$/, \"\") + \"](\" + location.href + \")\";\nnavigator.clipboard\n .writeText(str)\n .then(() => {\n alert('copied.')\n })\n .catch(() => {\n alert('Failed !')\n });\n",
"sites": "",
"sitesArray": [
""
]
},
{
"key": ", u",
"action": "javascript",
"code": "let str = document.title + \" \" + location.href;\nnavigator.clipboard\n .writeText(str)\n .then(() => {\n alert('copied.')\n })\n .catch(() => {\n alert('Failed !')\n });\n",
"sites": "",
"sitesArray": [
""
]
},
{
"action": "reopentab",
"key": "u",
"sites": "",
"sitesArray": [
""
]
},
{
"key": ", s",
"action": "javascript",
"code": "let str = \"[\" + location.href + \" \" + document.title.replace(/[\\[\\]]/g, \"\\\\$&\").replace(/\\\\$/, \"\") + \"]\"\nnavigator.clipboard\n .writeText(str)\n .then(() => {\n alert('copied.')\n })\n .catch(() => {\n alert('Failed !')\n });\n",
"sites": "",
"sitesArray": [
""
]
},
{
"key": ", e",
"action": "javascript",
"code": " var m = function (b) { b = b.replace(/&/g, \"&amp;\"); b = b.replace(/</g, \"&lt;\"); b = b.replace(/>/g, \"&gt;\"); b = b.replace(/\"/g, \"&quot;\"); return b = b.replace(/'/g, \"&#39;\") }, n = function (b) { b = void 0 === b ? 0 : b; for (var a = \"\", g = 1; g < b; g++)a += \" \"; return a }, p = function (b) {\n b = void 0 === b ? \"\" : b; var a = document.createElement(\"div\"); a.innerHTML = b; b = a.querySelectorAll(\"strong\"); for (var g = 0; g < b.length; g++) {\n var d = b[g], e = +d.className.split(\"level-\")[1], c = d.innerHTML; e = void 0 === e ? 1 : e; e = 6 - e; for (var f = \"\", h = 0; h < e; h++)f += \"#\"; d.innerHTML =\n f + \" \" + c\n } return a.innerHTML\n }, q = function (b) { b = void 0 === b ? \"\" : b; var a = document.createElement(\"div\"); a.innerHTML = b; b = a.querySelectorAll(\"a\"); for (var g = 0; g < b.length; g++) { var d = b[g], e = d.innerText.trim(), c = d.href; if (c.startsWith(\"https://scrapbox.io/chroju\")) continue; e = \"[\" + e + \"](\" + c + \")\"; var f = d.querySelector(\"img\"); null !== f && (e = \"[![Image](\" + f.src + \")](\" + c + \")\"); d.innerText = e } return a.innerText }, f = document.querySelector(\".lines\"), r = f.querySelector(\".line-title .text\").innerText; f = f.querySelectorAll(\".line\"); pageTexts = []; for (var l = 1; l < f.length; l++) {\n for (var c = f[l].querySelector(\".text\").cloneNode(!0),\n h = c.querySelectorAll(\"span.empty-char-index\"), a = 0; a < h.length; a++) { var k = h[a]; k.innerText = \"\" } h = c.querySelectorAll(\"span.backquote\"); for (a = 0; a < h.length; a++)k = h[a], k.innerText = \"`\"; a = c.innerHTML.replace(/<span>/g, \"\"); a = a.replace(/<span.+?>/g, \"\").replace(/<\\/span>/g, \"\"); a = a.replace(/<br.+?>/g, \"\"); a = a.replace(/\\n/gi, \"\").replace(/\\t/gi, \"\").trim(); a = p(a); a = q(a); c = c.querySelector(\".indent-mark\"); null !== c && (k = +c.style.width.split(\"em\")[0] / 1.5 * 2 - 1, a = n(k) + \"- \" + a); null === c && 0 < a.length && \"#\" !== a[0] && (a += \"<br>\"); pageTexts.push(a)\n } (function (b,\n a) { b = void 0 === b ? \"Title\" : b; a = void 0 === a ? [] : a; for (var c = \"# \" + b + \"\\n\", d = 0; d < a.length; d++)c += \"\\n\" + a[d]; a = window.open(); a.document.open(); a.document.write(\"<title>\" + b + \"</title>\"); a.document.write(\"<pre>\"); a.document.write(m(c)); a.document.write(\"</pre>\"); a.document.close() })(r, pageTexts)",
"sites": "https://scrapbox.io/",
"sitesArray": [
"https://scrapbox.io/"
],
"label": "Scrapbox to markdown",
"blacklist": "whitelist"
},
{
"key": ", j",
"label": "Scrapbox journal template",
"action": "javascript",
"code": " // ページ作成日時を入れたタイトルにする 例:「おしごとログ 2017-09-11」\n var dt = new Date();\n var journal_title = dt.getFullYear() + ' XX そのX : ';\n\n // ここがページ内容のテンプレート。1行目にタグをつけて、2行目は空、3行目は「ほにゃらら~」\n var lines = ['[journal] from [' + dt.getFullYear() + '-' + (\"0\" + (dt.getMonth() + 1)).slice(-2) + ']-XX to XXXX', '', '[**** 📌 Outcome]', '', '', '[**** 🖲️ Routine & Tools]', '', '', '[**** 📋 Clips]', '', '', '[**** 🏠 Life]', '', '', '[**** 🔍 Observe & Look back]', '', '', '[**** ⏭ Next]'];\n\n var body = encodeURIComponent(lines.join('\\n'));\n window.open('https://scrapbox.io/chroju/' + encodeURIComponent(journal_title.trim()) + '?body=' + body)",
"sites": "",
"sitesArray": [
""
]
},
{
"key": "j",
"action": "scrolldown",
"sites": "",
"sitesArray": [
""
],
"trigger": "ctrl+j ctrl+j"
},
{
"key": ", a",
"action": "javascript",
"code": "let asin = document.body.querySelector(\"input[name^='ASIN']\").value;\nlocation.href = 'https://amazon.co.jp/dp/' + asin;",
"sites": "",
"sitesArray": [
""
]
}
]
# vim: set filetype=vimrc:
# disabled for ShortKeys
unmap j
unmap k
unmap u
# remap default keys
unmap m
unmap T
unmap X
unmap d
map d removeTab
unmap t
map t Vomnibar.activateInNewTab
unmap <c-h>
map <c-h> moveTabLeft
map <c-l> moveTabRight
map b Vomnibar.activateTabSelection
map ;t LinkHints.activateModeToOpenInNewForegroundTab
map @ togglePinTab
map O Vomnibar.activateEditUrl
map l nextTab
map h previousTab
# qmarks
map gng createTab https://github.com/chroju
map gnk createTab https://booklog.jp/users/chroju/
map gnm createTab https://app.mailbrew.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment