Skip to content

Instantly share code, notes, and snippets.

@s-hiiragi
Last active July 17, 2019 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-hiiragi/4cbb7ff362060cf1a81207e703e79f37 to your computer and use it in GitHub Desktop.
Save s-hiiragi/4cbb7ff362060cf1a81207e703e79f37 to your computer and use it in GitHub Desktop.
Settings of 'Shortkeys' google chrome extension for DOVA-SYNDROME (dova-s.jp)
[{"action":"javascript","blacklist":"whitelist","code":"iframe = document.querySelector('#YouTube > iframe')\nid = iframe.src.match(/([0-9a-zA-Z]+)?$/)[0]\nhistory.go(id?-1:-2)","customName":"Go back","exported":true,"key":"a","open":false,"sites":"https://dova-s.jp/bgm/play*","sitesArray":["https://dova-s.jp/bgm/play*"]},{"action":"javascript","blacklist":"whitelist","code":"console.log('-- Play youtube movie')\niframe = document.querySelector('#YouTube > iframe')\nid = iframe.src.match(/([0-9a-zA-Z]+)?$/)[0]\nif (id) {\n\tiframe.src += `?autoplay=1&playlist=${id}&muted=1&`\n playedBgms = JSON.parse(localStorage.getItem('playedBgms')) || {}\n \ttitle = document.querySelector('#titleYouTube > h2').firstChild.textContent.trim()\n playedBgms[location.pathname] = title\n localStorage.setItem('playedBgms', JSON.stringify(playedBgms))\n console.log(playedBgms)\n} else {\n \thistory.go(-2)\n}","customName":"Play bgm","exported":true,"key":"space","open":false,"sites":"https://dova-s.jp/bgm/play*","sitesArray":["https://dova-s.jp/bgm/play*"]},{"action":"javascript","blacklist":"whitelist","code":"playedBgms = JSON.parse(localStorage.getItem('playedBgms')) || {}\nitems = Array.from(document.querySelectorAll('#itemList > .item'))\nhit = items.some((e, i) => {\n\tlet a = e.querySelector('a[href^=\"/bgm/play\"]')\n\tif (!playedBgms[a.getAttribute('href')]) {\n\t\ta.click()\n\t\treturn true\n\t}\n\treturn false\n})\nif (!hit) document.querySelector('#pageNavigation > .pager > a:last-of-type').click()","customName":"Go next bgm","exported":true,"key":"space","open":false,"sites":"https://dova-s.jp/bgm/index.html*\nhttps://dova-s.jp/bgm/","sitesArray":["https://dova-s.jp/bgm/index.html*","https://dova-s.jp/bgm/"]},{"key":"c","action":"javascript","blacklist":false,"sites":"*mail.google.com*","open":false,"customName":"Show checkboxs","code":"if (typeof checkBoxsShown === 'undefined') {\n\tcheckBoxsShown = true\n\tplayedBgms = JSON.parse(localStorage.getItem('playedBgms')) || {}\n\titems = Array.from(document.querySelectorAll('#itemList > .item'))\n\titems.forEach((e) => {\n\t\tlet a = e.querySelector('a[href^=\"/bgm/play\"]')\n\t\tlet checkBox = document.createElement('input')\n\t\tcheckBox.type = 'checkbox'\n\t\tcheckBox.checked = !!playedBgms[a.getAttribute('href')]\n\t\tcheckBox.onchange = (ev) => {\n\t\t\tif (checkBox.checked) {\n\t\t\t\ttitle = e.querySelector('dt a[href^=\"/bgm/play\"]').textContent.trim()\n\t\t\t\tplayedBgms[a.getAttribute('href')] = title\n\t\t\t} else {\n\t\t\t\tdelete playedBgms[a.getAttribute('href')]\n\t\t\t}\n\t\t\tlocalStorage.setItem('playedBgms', JSON.stringify(playedBgms))\n\t\t}\n\t\tlet p = e.querySelector('dt > p')\n\t\tp.insertBefore(checkBox, p.firstChild)\n\t})\n}","exported":true,"sitesArray":["*mail.google.com*"]}]
@s-hiiragi
Copy link
Author

@s-hiiragi
Copy link
Author

actions of 'space' key

  • go to the next bgm page
  • go to the next result page (when all bgms in the current result page have been played)
  • play the bgm
  • go back (when the bgm in the current bgm page have been played)

url patterns of result pages

an url pattern of bgm pages

@s-hiiragi
Copy link
Author

add an action (press 'c' key on a result page)

  • showing checkboxs to add/remove an entry that means whether a bgm played or not
    The entry is recorded into the localStorage on the site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment