|
1 | 1 | import { UfsGlobal } from "./content-scripts/ufs_global.js"; |
2 | | -import { |
3 | | - hookFetch, |
4 | | - hookXHR, |
5 | | - CANCEL_FETCH, |
6 | | - CANCEL_XHR, |
7 | | - cancelKey, |
8 | | -} from "./libs/ajax-hook/index.js"; |
9 | 2 |
|
10 | 3 | export default { |
11 | 4 | icon: "", |
@@ -262,23 +255,6 @@ export default { |
262 | 255 | }, |
263 | 256 |
|
264 | 257 | pageScript: { |
265 | | - onDocumentStart: () => { |
266 | | - // hookFetch({ |
267 | | - // onBefore: (url, options) => { |
268 | | - // console.log("onBefore", url, options); |
269 | | - // }, |
270 | | - // }); |
271 | | - const unregister = hookXHR({ |
272 | | - onBefore: (params) => { |
273 | | - if (params.url.includes("graphql")) console.log("before", params); |
274 | | - }, |
275 | | - onAfter: (params, response) => { |
276 | | - if (params.url.includes("graphql")) |
277 | | - console.log("-> after", params, JSON.parse(response)); |
278 | | - }, |
279 | | - }); |
280 | | - }, |
281 | | - |
282 | 258 | // download album |
283 | 259 | _onClick: async () => { |
284 | 260 | (async () => { |
@@ -717,52 +693,3 @@ export default { |
717 | 693 | }, |
718 | 694 | }, |
719 | 695 | }; |
720 | | - |
721 | | -const backup = () => { |
722 | | - (() => { |
723 | | - // modify window.fetch |
724 | | - const originalFetch = fetch; |
725 | | - fetch = function (...args) { |
726 | | - console.log("fetch", ...args); |
727 | | - return originalFetch(...args).then(async (res) => { |
728 | | - try { |
729 | | - console.log("res ne", res); |
730 | | - let clone = res.clone(); |
731 | | - let json = await clone.json(); |
732 | | - console.log("json", json); |
733 | | - |
734 | | - json = { |
735 | | - success: true, |
736 | | - data: {}, |
737 | | - }; |
738 | | - console.log("modifiedJson", json); |
739 | | - |
740 | | - let modifiedResponse = new Response(JSON.stringify(json)); |
741 | | - [ |
742 | | - "headers", |
743 | | - "ok", |
744 | | - "redirected", |
745 | | - "status", |
746 | | - "statusText", |
747 | | - "type", |
748 | | - "url", |
749 | | - ].forEach((key) => { |
750 | | - modifiedResponse[key] = res[key]; |
751 | | - }); |
752 | | - |
753 | | - console.log("modifiedResponse", modifiedResponse); |
754 | | - return modifiedResponse; |
755 | | - } catch (e) { |
756 | | - console.log("error", e); |
757 | | - return res; |
758 | | - } |
759 | | - }); |
760 | | - }; |
761 | | - })(); |
762 | | - |
763 | | - (() => { |
764 | | - chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { |
765 | | - console.log("onMessage", request, sender, sendResponse); |
766 | | - }); |
767 | | - })(); |
768 | | -}; |
0 commit comments