|
发表于
2022-12-31 12:10:23
|
显示全部楼层
请问是直接这样写吗,发现捕获不到啊,可以给个完整点的参考例子吗,急需。感谢!!!
- // ==UserScript==
- // [url=home.php?mod=space&uid=23356]@name[/url] [major]劫持并修改
- // @namespace https://bbs.tampermonkey.net.cn/
- // @version 0.1.0
- // @description try to take over the world!
- // @author You
- // [url=home.php?mod=space&uid=52134]@match[/url] {{match}}
- // @match http*://*/show?id*
- // @run-at document-start
- // ==/UserScript==
- (function() {
- const xhrOpen = XMLHttpRequest.prototype.open;
- XMLHttpRequest.prototype.open = function() {
- let url = '/api/show'
- if (arguments[1] == url) {
- const xhr = this;
- const getter = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'response').get;
- Object.defineProperty(xhr, 'response', {
- get: () => {
- let result = getter.call(xhr);
- console.log(result)
- //这里可以修改result
- return result;
- }
- });
- }
- return xhrOpen.apply(xhr, arguments);
- };
- })();
复制代码 |
|