Text Copy Enabler

Enable text copying on Japanese lyric websites

  1. // ==UserScript==
  2. // @name Text Copy Enabler
  3. // @name:ja Text Copy Enabler
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.3
  6. // @description Enable text copying on Japanese lyric websites
  7. // @description:ja 日本語歌詞サイトでのテキストコピーを可能にします
  8. // @author Tonikkl
  9. // @match https://www.oricon.co.jp/prof/*/lyrics/*/
  10. // @match https://www.uta-net.com/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. if (window.location.href.indexOf('www.oricon.co.jp') > -1) {
  18. // Override CSS properties to enable text selection
  19. var styleOricon = document.createElement('style');
  20. styleOricon.innerHTML = '.all-lyrics { user-select: text !important; -webkit-user-select: text !important; }';
  21. document.head.appendChild(styleOricon);
  22.  
  23. // Remove the oncontextmenu, onmousedown, and onselectstart attributes
  24. var elements = document.querySelectorAll('.all-lyrics');
  25. for (var i = 0; i < elements.length; i++) {
  26. elements[i].removeAttribute('oncontextmenu');
  27. elements[i].removeAttribute('onmousedown');
  28. elements[i].removeAttribute('onselectstart');
  29. }
  30. }
  31.  
  32. if (window.location.href.indexOf('www.uta-net.com') > -1) {
  33. // Override CSS properties to enable text selection and interaction
  34. var styleUtaNet = document.createElement('style');
  35. styleUtaNet.innerHTML = `
  36. .nocopy, .nocopy * {
  37. user-select: text !important;
  38. -webkit-user-select: text !important;
  39. pointer-events: auto !important;
  40. }
  41. `;
  42. document.head.appendChild(styleUtaNet);
  43.  
  44. // Disable common event listeners which might prevent copying
  45. window.addEventListener('contextmenu', function(e) {
  46. e.stopPropagation();
  47. }, true);
  48.  
  49. window.addEventListener('selectstart', function(e) {
  50. e.stopPropagation();
  51. }, true);
  52.  
  53. window.addEventListener('mousedown', function(e) {
  54. e.stopPropagation();
  55. }, true);
  56.  
  57. window.addEventListener('mouseup', function(e) {
  58. e.stopPropagation();
  59. }, true);
  60. }
  61. })();