Allow Copy and Context Menu Continued

Allow Copy (include hot keys and some css) & Context Menu. Disable (remove) copy text protection and allow copy for all sites. Thanks Lex1 for example http://lexi.ucoz.ru/buttons.html

  1. // ==UserScript==
  2. // @name Allow Copy and Context Menu Continued
  3. // @version 7.3.4
  4. // @author Anonimous
  5. // @namespace https://gf.qytechs.cn/en/users/16081-lolipop
  6. // @description Allow Copy (include hot keys and some css) & Context Menu. Disable (remove) copy text protection and allow copy for all sites. Thanks Lex1 for example http://lexi.ucoz.ru/buttons.html
  7. // @include *
  8. // @license GPL version 3 or any later version; www.gnu.org/licenses/gpl-3.0.en.html
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. ;(function(){
  14.  
  15. /* handler names */
  16. /*
  17. * NOTE! 'drag', 'dragend', 'dragstart' - when drag text, use alt + selection for text or add them to array
  18. */
  19. var handlerNameArr = ['contextmenu', 'copy', 'cut', 'paste', 'mousedown', 'mouseup', 'beforeunload', 'beforeprint', 'keyup', 'keydown', 'select', 'selectstart'];
  20.  
  21. /* remove protection of window */
  22. var removeProtection = function removeProtectionName(protectedWindow) {
  23.  
  24. /*
  25. * document object in frames is same as window https://developer.mozilla.org/en-US/docs/Web/API/Window/frames
  26. * frames == iframe + frame
  27. */
  28. for(var i=0; i < handlerNameArr.length; i++){
  29. var handlerName = handlerNameArr[i];
  30. var handlerOnName = 'on' + handlerName;
  31. if(protectedWindow[handlerOnName])
  32. protectedWindow[handlerOnName] = null;
  33. protectedWindow.addEventListener(handlerName, function(e){ e.stopPropagation(); }, true);
  34. }
  35.  
  36. };
  37. /* remove css protection */
  38. var removeCssProtection = function removeCssProtectionName() {
  39. var cssStyle = '* { -moz-user-select: text !important; user-select: text !important; } ';
  40. //GreaseMonkey only
  41. /* @grant GM_addStyle need */
  42. //GM_addStyle(cssStyle);
  43. var style = document.createElement('style');
  44. style.type = 'text/css';
  45. style.innerHTML = cssStyle;
  46. document.head.appendChild(style);
  47. };
  48.  
  49. /* remove main window protection */
  50. removeProtection(window);
  51.  
  52. /* remove frame window protection */
  53. var frameList = window.frames;
  54.  
  55. for(var i = 0; i < frameList.length; i++) {
  56. try{
  57. removeProtection(frameList[i]);
  58. } catch(e){
  59. }
  60. }
  61. removeCssProtection();
  62.  
  63. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址