Created
January 1, 2025 13:49
-
-
Save mdashlw/4c48ae26aeef1661b149f064cc69a05b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Tumblr No Reblogs | |
| // @match https://*.tumblr.com/* | |
| // @version 1.0 | |
| // @author mdashlw | |
| // @run-at document-start | |
| // @inject-into page | |
| // ==/UserScript== | |
| const _fetch = unsafeWindow.fetch; | |
| function patchResponse(response, patcher) { | |
| const _json = response.json; | |
| response.json = async function () { | |
| const json = await _json.call(this); | |
| patcher(json); | |
| return json; | |
| }; | |
| return response; | |
| } | |
| unsafeWindow.fetch = function () { | |
| const url = arguments[0]; | |
| if (typeof url === "string") { | |
| if (url.includes("/posts?fields") && url.includes("&context=archive")) { | |
| return _fetch.apply(this, arguments).then((response) => | |
| patchResponse(response, (json) => { | |
| const posts = | |
| json.response.posts?.filter((post) => !post.rebloggedRootId) ?? []; | |
| if (!posts.length && json.response.posts?.length) { | |
| posts.push(json.response.posts[0]); | |
| } | |
| json.response.posts = posts; | |
| }), | |
| ); | |
| } | |
| } | |
| return _fetch.apply(this, arguments); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment