I want to copy some content from a website that has copy disabled by this part
$(document).bind('copy', function(e){
return false;
});
I tried to unbind the function with $(document).off('copy'), and it works flawlessly in the console, but when in userscript it does not work.
I used Tampermonkey userscript to create a button to copy all content from a class with these lines
// Everything in this code block works in the console...
$(document).off('copy');
range.selectNode(document.getElementsByClassName('bbWrapper')[0]);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
Already have this in header // @require https://code.jquery.com/jquery-3.6.0.min.js
Also done this var $ = window.jQuery;
@requireand add// @grant noneso the script will use jquery of the site.// @grant nonehas been there the whole time. I didn't delete it. I managed to get it right by usinghttps://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.jsinstead ofhttps://code.jquery.com/jquery-3.6.0.min.js. Thanks to this answer here@grant noneis ignored if you have other@grantvalues.