moneymuseum.by: PDP: add button to copy a title without spaces

This is bad to have spaces in file names

目前為 2024-06-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name moneymuseum.by: PDP: add button to copy a title without spaces
  3. // @namespace Violentmonkey Scripts
  4. // @match https://moneymuseum.by/*
  5. // @version 1.0
  6. // @author Vitaly Zdanevich
  7. // @description This is bad to have spaces in file names
  8. // ==/UserScript==
  9.  
  10.  
  11. (function() {
  12. if (document.querySelector('.product-item-detail-slider-image').length === 0) {
  13. return // This is not a PDP
  14. }
  15.  
  16. const h1 = document.querySelector('h1')
  17.  
  18. const span = document.createElement('span')
  19. span.style='margin:10px; font-style:italic; color:green; cursor:pointer'
  20. span.onclick=function() {
  21. this.remove()
  22. const text = h1.innerText
  23. .replace(/\s/g, '_')
  24. .replaceAll(',', '')
  25. navigator.clipboard.writeText(text)
  26. }
  27. span.innerText = 'copy'
  28.  
  29. h1.append(span)
  30. })()