🏠 Home 

stop misoperation

when u using prd env,it can stop misoperation!!


Install this script?
  1. // ==UserScript==
  2. // @name stop misoperation
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description when u using prd env,it can stop misoperation!!
  6. // @author double jy
  7. // @match https://www.baidu.com
  8. // @grant none
  9. // ==/UserScript==
  10. function ajaxSend(objectOfXMLHttpRequest, callback) {
  11. if(!callback){
  12. return;
  13. }
  14. var s_ajaxListener = new Object();
  15. s_ajaxListener.tempOpen = objectOfXMLHttpRequest.prototype.open;
  16. s_ajaxListener.tempSend = objectOfXMLHttpRequest.prototype.send;
  17. s_ajaxListener.callback = function () {
  18. // this.method :the ajax method used
  19. // this.url :the url of the requested script (including query string, if any) (urlencoded)
  20. // this.data :the data sent, if any ex: foo=bar&a=b (urlencoded)
  21. callback(this.method, this.url, this.data);
  22. }
  23. objectOfXMLHttpRequest.prototype.open = function(a,b) {
  24. if (!a) a='';
  25. if (!b) b='';
  26. s_ajaxListener.tempOpen.apply(this, arguments);
  27. s_ajaxListener.method = a;
  28. s_ajaxListener.url = b;
  29. if (a.toLowerCase() == 'get') {
  30. s_ajaxListener.data = b.split('?');
  31. s_ajaxListener.data = s_ajaxListener.data[1];
  32. }
  33. }
  34. objectOfXMLHttpRequest.prototype.send = function(a,b) {
  35. if(s_ajaxListener.method.toLowerCase() == 'post' && s_ajaxListener.url.indexOf('https://www.baidu.com') >= 0){
  36. if(!confirm("你确定要操作线上环境??????????"))return;
  37. }
  38. if (!a) a='';
  39. if (!b) b='';
  40. s_ajaxListener.tempSend.apply(this, arguments);
  41. if(s_ajaxListener.method.toLowerCase() == 'post') {
  42. s_ajaxListener.data = a;
  43. }
  44. s_ajaxListener.callback();
  45. }
  46. };
  47. function onAjaxSend(method, url, data) {
  48. if(method=='POST'){
  49. }
  50. };
  51. (function() {
  52. 'use strict';
  53. // Your code here...
  54. ajaxSend(globalThis.XMLHttpRequest, onAjaxSend);
  55. })();