JQ_ForceAutoComplete

Forces the autocomplete attribute for all forms and input fields in the page

  1. // ==UserScript==
  2. // @name JQ_ForceAutoComplete
  3. // @namespace http://stackoverflow.com/users/982924/rasg
  4. // @author RASG
  5. // @version 2017.04.15
  6. // @description Forces the autocomplete attribute for all forms and input fields in the page
  7. // @require http://code.jquery.com/jquery.min.js
  8. // @include http*://*
  9. // ==/UserScript==
  10.  
  11. if (window.$ !== undefined) { $ = window.$ }
  12. else if (unsafeWindow.$ !== undefined) { $ = unsafeWindow.$ }
  13. else { this.$ = this.jQuery = jQuery.noConflict(true); }
  14.  
  15. $(window).load(function(){
  16.  
  17. // ---
  18. // SELECT ELEMENTS TO WORK ON
  19. // ---
  20.  
  21. $("body").on("focus click", "form" , function() { parse( this ) });
  22. $("body").on("focus click", "input", function() { parse( this ) });
  23.  
  24. // ---
  25. // FUNCTION TO ADD / REMOVE ATTRIBUTES FROM THE ELEMENTS
  26. // ---
  27.  
  28. function parse(element) {
  29.  
  30. //console.log(element);
  31.  
  32. $(element).removeAttr("disabled readonly");
  33. $(element).removeProp("disabled readonly");
  34.  
  35. $(element).attr("autocomplete", "on");
  36. $(element).prop("autocomplete", "on");
  37. }
  38.  
  39. // ---
  40. // KNOWN FUNCTIONS THAT PREVENTS AUTOCOMPLETE FROM WORKING
  41. // ---
  42.  
  43. unsafeWindow.C = function(G) { return false };
  44.  
  45. });