- Adam Douglas
- technology
As we browse and use websites for variety of reasons you may have unfortunate experience of trying to copy and pastetext into a form field to discover that the ability has been disabled. Restricting or preventing pasting of text breaksthe natural flow of data entry that leads to frustration for a user and takes away their authority to make this decisionon their own. It is even worse for those that choose to use a password manager to login into a website. No one wants tomanually type in a secure password. For better or worse this is happening, so here are a few ways that one can take yourauthority back by blocking this unwanted behaviour.
Environment
Tested using the following.
- Mozilla Firefox v123.0 (64-bit)
- Google Chrome/Chromium v122.0.6261.69 (64-bit)
Problem
Unable to copy and paste when interacting with certain websites (e.g. password field).
Solution - Browser Extension
There are a few options available by installing a web browser extension or add-on. However, this comes with a potentialprivacy risk. Make sure to review the permissions granted for the desired extension or add-on. Which ever solution ischosen, don’t forget to verify it’s working.
- Don’t f*** with copy and paste
- Prevents the blocking of copying from and pasting into web form input fields for all or specific websites.
- Chrome web store | Firefox Browser Add-Ons | Chrome/Chromium Project | Firefox Port
- NoScript
- Allow JavaScript to run only on the trusted domains of your choice while protecting against cross-site scripting (XSS), cross-zone DNS rebinding / CSRF attacks (router hacking) and clickjacking attempts.
- Chrome web store | Firefox Browser Add-Ons | Website
Solution - Bookmarklet
Through the use of JavaScript a bookmarklet provides added features to a web browser and is only ran locally when youclick on it. A bookmarklet is conveniently stored within a web browser’s bookmarks. This method has the risk ofcontaining malicious JavaScript code, therefore it is strongly recommended reviewing and understand the JavaScript codebefore using to ensure it is safe to use.
To install the bookmarklet below simply click on “Allow Copy & Paste” and then drag into your bookmarks. Then wheneveran issue arises that is preventing you from copy and pasting simply click on the saved bookmarklet to fix it.
Allow Copy & Paste
The bookmarklet source code uses event listeners to prevent other listeners of the same event from being called.
javascript: (function () { allowCopyAndPaste = function (e) { e.stopImmediatePropagation(); return true; }; document.addEventListener("copy", allowCopyAndPaste, true); document.addEventListener("paste", allowCopyAndPaste, true); document.addEventListener("onpaste", allowCopyAndPaste, true);})();
Solution - Mozilla Firefox Config
This method is a very effective, but it has a couple caveats. By disabling the clipboard events this will affect allwebsites one may visit until it is re-enabled, and it may break some websites intended functionality. As well thisisn’t exactly convenient having to enable or disable this configuration.
- Open the Mozilla Firefox web browser.
-
In the address bar enter
about:config
and press the Enter key. -
Click on the button “Accept the Risk and Continue”.
-
In the search input field enter
dom.event.clipboardevents.enabled
. -
Double-click on the value to change from
true
tofalse
fordom.event.clipboardevents.enabled
. -
Verify changes.
Test it’s working by using the provided form.
Solution - Manual JavaScript
The JavaScript source code is manually run by using the console found within the Web Developer Tools. This method willrequire running this code each and every time. The source code functions by using event listeners to prevent otherlisteners of the same event from being called.
- Open Mozilla Firefox or Google Chrome/Chromium web browser.
- Browse to the defending website that is not allowing you to copy and paste into a form field.
- Press the F12 key for Web Developer Tools.
- Click on “Console” in the top navigation.
-
Grant code pasting permission if using Google Chrome/Chromium.
Type “allow pasting” without double quotes into the console and press the Enter key.
-
Within the Console paste the following JavaScript code.
var allowCopyAndPaste = function (e) { e.stopImmediatePropagation(); return true;};document.addEventListener("copy", allowCopyAndPaste, true);document.addEventListener("paste", allowCopyAndPaste, true);document.addEventListener("onpaste", allowCopyAndPaste, true);
-
Verify changes.
Test it’s working by using the provided form.
Solution - Disable JavaScript
This method is not convenient, but without a doubt works very effectively. However, with JavaScript disabled this maycause some websites to not function properly.
Google Chrome/Chromium
- Open the Google Chrome/Chromium web browser.
-
Choose one of the following methods.
-
Enter address.
In the address bar enter,
chrome://settings/content/javascript
and press the Enter. -
Follow these steps.
- Click on context menu (three vertical dots).
- Browse to “Privacy and security” > “site settings” > “JavaScript”.
-
-
Disable JavaScript using one of two methods.
- Click on “Don’t allow sites to use JavaScript”
- Under “Customized behaviors” click on the “Add” button for allow or deny and enter website address.
-
Verify changes.
Test it’s working by using the provided form.
Mozilla Firefox
- Open the Mozilla Firefox web browser.
-
In the address bar enter
about:config
and press the Enter key. -
Click on the button “Accept the Risk and Continue”.
- In the search input field enter
javascript.enable
. - Double-click on the value to change from
true
tofalse
forjavascript.enable
. -
Verify changes.
Test it’s working by using the provided form.
Verify Solutions
This form input is for testing purposes that has copy and paste disabled in order to test if the solution chosen works.A successful solution will allow text to be pasted into the form field below otherwise the paste will fail.
Support Adamsdesk
Direct support from our audience allows for us to achieve our goal of sustainability. Cast Your Vote of Support.
Donate Affiliates
References
- About:config - MozillaZine Knowledge Base
- Bookmarklet - Wikipedia
- Configuration Editor for Firefox - Firefox Help
- Event: stopImmediatePropagation method() - Web APIs - MDN
- EventTarget: addEventListener() method - Web APIs - MDN
- Post image created in Inkscape
- Post image modifications, add background, add road, add barrier, add text, add logo, add lines
- Post image uses barrier
- Post image uses Bevan font by Vernon Adams
- Post image uses Fira Sans font by Mozilla
- Post image uses road
Comments
Reply via Email