HOW TO turn off copy-pasting restrictions on web form fields of annoying websites

Some sites disallow pasting values into text boxes within a form. This can be annoying if the content that is to be copied is a very long or is so cryptic that you have to copy it from somewhere else carefully character by character.

Some websites implement it using the onpaste event:
<input class="yellowtextbox" name="txtCustomerID1" maxlength="10" onpaste="return false;">

Derek Prior has written a bookmarklet that deactivates the functionality that prevents values from being pasted into text fields. Copy the bookmarklet to your browser's bookmarklet bar and click on it while you're on the annoying web page that disables pasting values.

His code works for password fields. It can be made to work for input fields like textboxes as well by commenting a couple of lines.

var inputs = document.getElementsByTagName('input');
for (var i=0; i < inputs.length; i++) {
 // if (inputs[i].getAttribute('type').toLowerCase() === 'password') {
    inputs[i].setAttribute('onpaste', '');
//  }
}

Chris Bailey has improved code that can work on web forms which have this feature implemented not declaratively as in the above case but through JavaScript or jQuery.

This is a bit of a hassle but another alternative is to disable JavaScript temporarily for that page which will in turn will turn off the JavaScript paste blocker. For Chrome, the keyboard shortcut to open Dev Tools is F12, to reach the Settings panel is F1 & here you'll find the checkbox to Disable JavaScript in the General section.
The idea of neutralizing an event within an external page through code in a bookmarklet can be extended to other scenarios.

Some websites take text selected by a user within a page & show some UI effect like a balloon, tooltip or an alert with content related to the selected text. If the purpose of that effect doesn't improve the reading experience, it can be gotten rid off.

For example, this implementation shows an alert with selected text when a user selects text as that action is bound to the mouseup event. I was able to disable that effect by using this bookmarklet code that unbinds the mouseup event:

javascript:(function(){ $(document).unbind('mouseup')})();

As the way that functionality is implemented on each site can vary (the function to trigger an alert/pop up could be tied to a specific paragraph or div and that too with a different event), writing a generic solution to disable that effect through a single bookmarklet can be challenging as it has take care of the different ways that feature is implemented.

Related: Dictionary Bookmarklet

Comments

Popular posts from this blog

Maven Crash Course - Learn Power Query, Power Pivot & DAX in 15 Minutes

"Data Prep & Exploratory Data Analysis" course by Maven Analytics

Oracle Cloud Infrastructure 2024 Generative AI Professional Course & Certification Exam (1Z0-1127-24)