Last active
September 5, 2023 19:59
-
-
Save claudio4/39f38e228e8d0d9952dc946e61639dc1 to your computer and use it in GitHub Desktop.
Bookmarklet to prevent sites from messing with the copy/paste events. Executing it a second time restore the sites normal behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
function showModal(message) { | |
const main = document.createElement('div'); | |
main.style.position = 'fixed'; | |
main.style.top = '16px'; | |
main.style.width = '80vw'; | |
main.style.left = '50%'; | |
main.style.transform = 'translateX(-50%)'; | |
main.style.maxWidth = '800px'; | |
main.style.backgroundColor = 'rgba(255, 218, 121,0.8)'; | |
main.style.border = '2px solid #000'; | |
main.style.borderRadius = '4px'; | |
main.style.padding = '8px'; | |
main.style.zIndex = '9999999'; | |
main.style.textAlign = 'center'; | |
main.style.color = '#000'; | |
main.style.fontFamily = 'sans-serif'; | |
main.innerText = message; | |
const timeout = setTimeout(() => { | |
main.remove(); | |
}, 2000); | |
main.addEventListener('click', () => { | |
main.remove(); | |
clearTimeout(timeout); | |
}); | |
document.body.appendChild(main); | |
} | |
if (window.__cl4PreventPropagation) { | |
document.removeEventListener('paste', window.__cl4PreventPropagation, true); | |
document.removeEventListener('copy', window.__cl4PreventPropagation, true); | |
delete window.__cl4PreventPropagation; | |
showModal('Page specific copy and paste behavior has been restored.'); | |
} else { | |
window.__cl4PreventPropagation = function(e) { | |
e.stopImmediatePropagation(); | |
}; | |
document.addEventListener('paste', window.__cl4PreventPropagation, true); | |
document.addEventListener('copy', window.__cl4PreventPropagation, true); | |
showModal('The page no longer will interfere with your copy and paste actions.'); | |
} | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){function showModal(message){const main=document.createElement('div');main.style.position='fixed';main.style.top='16px';main.style.width='80vw';main.style.left='50%';main.style.transform='translateX(-50%)';main.style.maxWidth='800px';main.style.backgroundColor='rgba(255, 218, 121,0.8)';main.style.border='2px solid #000';main.style.borderRadius='4px';main.style.padding='8px';main.style.zIndex='9999999';main.style.textAlign='center';main.style.color='#000';main.style.fontFamily='sans-serif';main.innerText=message;const timeout=setTimeout(()=>{main.remove();},2000);main.addEventListener('click',()=>{main.remove();clearTimeout(timeout);});document.body.appendChild(main);}if(window.__cl4PreventPropagation){document.removeEventListener('paste',window.__cl4PreventPropagation,true);document.removeEventListener('copy',window.__cl4PreventPropagation,true);delete window.__cl4PreventPropagation;showModal('Page specific copy and paste behavior has been restored.');}else{window.__cl4PreventPropagation=function(e){e.stopImmediatePropagation();};document.addEventListener('paste',window.__cl4PreventPropagation,true);document.addEventListener('copy',window.__cl4PreventPropagation,true);showModal('The page no longer will interfere with your copy and paste actions.');}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment