jQuery Element Logger para chrome v.54+

Añade la funcionalidad de Log al navegador Chrome, desparacida a partir de la version 54

  1. // ==UserScript==
  2. // @name jQuery Element Logger para chrome v.54+
  3. // @description Añade la funcionalidad de Log al navegador Chrome, desparacida a partir de la version 54
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.2
  6. // @author Divisadero LABS
  7. // @match http*://*/*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12.  
  13. window.logManager = {
  14. debug:false,
  15. trigger:localStorage.getItem('dsd_logmanager') || "LOAD",
  16. triggerDictionary: ["ALWAYS","READY","LOAD","NEVER"],
  17. setTrigger:function(moment){
  18. if(this.triggerDictionary.indexOf(moment) > -1){
  19. localStorage.setItem('dsd_logmanager',moment);
  20. this.trigger = moment;
  21. this.executeTrigger();
  22. }else{
  23. console.error('Error logManager: Not a valid trigger. Possible Values ["ALWAYS","READY","LOAD","NEVER"]');
  24. return false;
  25. }
  26. },
  27. executeTrigger: function(){
  28. switch(this.trigger){
  29. case "ALWAYS":
  30. this.debug = true;
  31. break;
  32. case "READY":
  33. var _self = this;
  34. document.addEventListener('DOMContentLoaded', function() {
  35. _self.debug = true;
  36. });
  37. break;
  38. case "LOAD":
  39. var _self = this;
  40. window.addEventListener('load', function() {
  41. _self.debug = true;
  42. });
  43. break;
  44. case "NEVER":
  45. this.debug = false;
  46. break;
  47. }
  48. },
  49. log:function(){
  50. if(this.debug){
  51. console.log.apply(this,arguments);
  52. }
  53. }
  54. };
  55. logManager.executeTrigger();
  56. var jQueryInterval = setInterval(function(){
  57. if(window.jQuery){
  58. clearInterval(jQueryInterval);
  59. (function($) {
  60. var jQueryInit = $.fn.init;
  61.  
  62. $.fn.init = function(arg1, arg2, rootjQuery){
  63. var jQueryShit = new jQueryInit(arg1, arg2, rootjQuery);
  64. for(var i = 0; i < jQueryShit.length; i++){
  65. logManager.log(jQueryShit[i]);
  66. }
  67. return jQueryShit;
  68. };
  69. })(jQuery);
  70. }
  71. },100);
  72. // After 5 seconds of not jQuery loaded the interval is removed
  73. setTimeout(function(){clearInterval(jQueryInterval);},5000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址