Sleazy Fork is available in English.

ASMR Online 一键复制名称

给目录树的每个音声加上复制名称的按钮

  1. // ==UserScript==
  2. // @name ASMR Online 一键复制名称
  3. // @name:zh-CN ASMR Online 一键复制名称
  4. // @name:en ASMR Online copy title name
  5. // @namespace ASMR-ONE
  6. // @version 0.1
  7. // @description 给目录树的每个音声加上复制名称的按钮
  8. // @description:zh-CN 给目录树的每个音声加上复制名称的按钮
  9. // @description:en Add a button to copy title for each file in working tree
  10. // @author moriya
  11. // @license MIT
  12. // @match https://www.asmr.one/work/*
  13. // @icon https://www.asmr.one/statics/app-logo-128x128.png
  14. // ==/UserScript==
  15.  
  16. (function __MAIN__ () {
  17. 'use strict';
  18.  
  19. const aBtnEle = document.createElement('button')
  20. aBtnEle.style.border = 'none'
  21. aBtnEle.classList.add(...'q-btn-item non-selectable no-outline q-btn--standard q-btn--rectangle bg-cyan shadow-4 q-mx-xs q-px-sm text-white q-btn--actionable q-btn--wrap q-btn--dense'.split(' '))
  22. aBtnEle.textContent = 'copy'
  23. aBtnEle.setAttribute('data-xxcopy', true)
  24.  
  25. const listContainer = document.getElementById('work-tree').getElementsByClassName('q-card')[0].children[0]
  26. const Observer = new MutationObserver(() => {
  27.  
  28. const items = listContainer.querySelectorAll('[role="listitem"]');
  29.  
  30. items.forEach(li => {
  31. const lastChild = li.lastElementChild
  32. if (!lastChild.getAttribute('data-xxcopy')) {
  33. const btnEle = aBtnEle.cloneNode(true)
  34.  
  35. li.appendChild(btnEle)
  36. btnEle.addEventListener('click', (ev) => {
  37. ev.stopPropagation()
  38.  
  39. copy(li.children[2].children[0].textContent)
  40. })
  41. }
  42.  
  43. })
  44. });
  45. Observer.observe(listContainer, { childList: true })
  46.  
  47. function copy(title) {
  48. const type = "text/plain";
  49. const blob = new Blob([title], { type });
  50. const data = [new ClipboardItem({ [type]: blob })];
  51. navigator.clipboard.write(data)
  52. }
  53.  
  54. })();