Skip to content

Instantly share code, notes, and snippets.

@tiglek
Last active August 29, 2020 06:39
Show Gist options
  • Save tiglek/02ead288509c92b8efa5c2cc05d881e1 to your computer and use it in GitHub Desktop.
Save tiglek/02ead288509c92b8efa5c2cc05d881e1 to your computer and use it in GitHub Desktop.
Re-enable the COPY from a copy-protected web page on a chrome browser
//
// See https://github.com/FallenMax/chrome-extension-allow-copy/blob/master/extension/content_scripts/unlocker.js
//
((frame) => {
[
'copy', 'cut', 'contextmenu', 'selectstart', 'mousedown', 'mouseup', 'mousemove', 'keydown', 'keypress', 'keyup'
].forEach(evt => {
frame.document.documentElement.addEventListener(evt, e => {
e.stopPropagation();
e.stopImmediatePropagation && e.stopImmediatePropagation();
}, {
capture: true,
})
});
const style = frame.document.createElement('STYLE');
style.innerHTML = 'html,body,*,*::before,*::after { -webkit-user-select: initial !important; user-select: initial !important; }';
frame.document.documentElement.append(style);
})(window); // or window['frame_id']
@tiglek
Copy link
Author

tiglek commented Jul 5, 2020

Usage

  • Open a development tool console on a chrome browser.
  • Copy and paste the code above into the console.

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