Getman+

Getman HTTP接口请求模拟测试工具增强插件,在线Postman,在线Curl,支持Cookie、本地内网跨域请求 Restful接口测试

  1. // ==UserScript==
  2. // @name Getman+
  3. // @namespace Getman.cn
  4. // @version 1.0
  5. // @description Getman HTTP接口请求模拟测试工具增强插件,在线Postman,在线Curl,支持Cookie、本地内网跨域请求 Restful接口测试
  6. // @author Getman.cn
  7. // @match https://getman.cn/*
  8. // @grant GM_xmlhttpRequest
  9. // @connect *
  10. // @run-at document-end
  11. // @homepage https://getman.cn/
  12. // @icon https://getman.cn/img/icon.png
  13. // @supportURL https://getman.cn/
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict';
  18. var delay = 500;
  19. var timeout = 10000;
  20. setTimeout(function () {
  21. if (typeof (unsafeWindow.localRequest) === 'function') {
  22. unsafeWindow.localRequest = function () {
  23. GM_xmlhttpRequest({
  24. method: unsafeWindow.request.request.method,
  25. url: unsafeWindow.request.request.url.raw,
  26. headers: Object.assign({}, unsafeWindow.request.request.header),
  27. data: unsafeWindow.request.request.body,
  28. timeout: timeout,
  29. onload: function (res) {
  30. unsafeWindow.request.response.code = res.status || 0;
  31. unsafeWindow.request.response.status = res.statusText || '';
  32. unsafeWindow.request.response.header = unsafeWindow.kvStringToObject(res.responseHeaders || '');
  33. unsafeWindow.request.response.body = res.responseText || '';
  34. unsafeWindow.showResponseData(res);
  35. },
  36. onerror: function (res) {
  37. unsafeWindow.request.response.code = res.status || 0;
  38. unsafeWindow.request.response.status = res.statusText || '';
  39. unsafeWindow.request.response.header = unsafeWindow.kvStringToObject(res.responseHeaders || '');
  40. unsafeWindow.request.response.body = res.responseText || '';
  41. unsafeWindow.showResponseData(res);
  42. },
  43. ontimeout: function (res) {
  44. unsafeWindow.request.response.code = res.status || 0;
  45. unsafeWindow.request.response.status = res.statusText || '';
  46. unsafeWindow.request.response.header = unsafeWindow.kvStringToObject(res.responseHeaders || '');
  47. unsafeWindow.request.response.body = res.responseText || '';
  48. unsafeWindow.showResponseData(res);
  49. }
  50. });
  51. }
  52. }
  53.  
  54. }, delay);
  55.  
  56. })();