Skip to content

Instantly share code, notes, and snippets.

@Gustavo-Kuze
Last active April 30, 2024 13:22
Show Gist options
  • Save Gustavo-Kuze/32959786ce55b2c3751629e40c75c935 to your computer and use it in GitHub Desktop.
Save Gustavo-Kuze/32959786ce55b2c3751629e40c75c935 to your computer and use it in GitHub Desktop.
Enable copy and paste in a webpage from the browser console
javascript:(function(){
  allowCopyAndPaste = function(e){
  e.stopImmediatePropagation();
  return true;
  };
  document.addEventListener('copy', allowCopyAndPaste, true);
  document.addEventListener('paste', allowCopyAndPaste, true);
  document.addEventListener('onpaste', allowCopyAndPaste, true);
})(); 
@tannguyen2001
Copy link

Thanks

@oritorius
Copy link

Thanks.

@liuliangsir
Copy link

Thanks

@AmetuerCodr
Copy link

thanks

@ferreraa
Copy link

ferreraa commented May 2, 2023

thanks

@klmnweb
Copy link

klmnweb commented May 3, 2023

Thanks. it's worked.

@UltraSabreman
Copy link

Thanks

@Darthagnon
Copy link

Thanks

@StephanieSunshine
Copy link

Thanks, any chance you can fix the thing that breaks reader mode with the W. W. Norton books too?

@Musab-Hassan
Copy link

Musab-Hassan commented May 14, 2023

This does not seem to work for Mcgraw Hill books, I modified it for anybody struggling with copy pasting from there. Here's a modified version.

javascript:(function(){
  allowCopyAndPaste = (e) => {
  e.stopImmediatePropagation();
  return true;
  };
  
  document.addEventListener('copy', allowCopyAndPaste, true);
  document.addEventListener('paste', allowCopyAndPaste, true);
  document.addEventListener('onpaste', allowCopyAndPaste, true);
  document.addEventListener('mousedown', allowCopyAndPaste, true);
  document.addEventListener('mouseup', allowCopyAndPaste, true);
  document.addEventListener('selectstart', allowCopyAndPaste, true);
  document.addEventListener('selectionchange', allowCopyAndPaste, true);
})();

You probably will have to refresh your page after copying as this can potentially break certain buttons and links.

@StephanieSunshine
Copy link

I finally got a chance to test this with one of the W.W. Norton books, it doesn't seem to work.n When you highlight something it has a popup dialog that tries to hijack your clipboard.

@agarzon
Copy link

agarzon commented Jan 31, 2024

Does not work in some bank websites

@yacanka
Copy link

yacanka commented Feb 13, 2024

Thanks.

@emarashliev
Copy link

Awesome! Thank you!

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