Skip to content

Commit 88a5520

Browse files
committed
reddit.com: load media as blobs
1 parent 0c6f494 commit 88a5520

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

reddit.com/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ sheet.type = "text/css";
1212
sheet.innerText = styles;
1313
document.head.appendChild(sheet);
1414

15+
const sections = location.pathname.split(/(?!^)\//);
16+
const loc = sections[0];
17+
18+
if (["/media"].includes(loc)) {
19+
const i = new URLSearchParams(location.search).get("url");
20+
fetch(i)
21+
.then((response) => response.blob())
22+
.then((blob) => {
23+
const objectURL = URL.createObjectURL(blob);
24+
location.href = objectURL;
25+
});
26+
}
27+
1528
// hide multi-reddits by default
1629
setTimeout(() => {
1730
const customFeeds = document.querySelector(
@@ -43,7 +56,6 @@ const observer = new MutationObserver((mutations, _) => {
4356
});
4457

4558
observer.observe(targetNode, config);
46-
4759
/**
4860
*
4961
*/
@@ -53,8 +65,6 @@ function run_it(node = document) {
5365
return;
5466
}
5567

56-
const sections = location.pathname.split(/(?!^)\//);
57-
const loc = sections[0];
5868
if (["/user", "/r"].includes(loc)) {
5969
for (const element of node.querySelectorAll("a")) {
6070
const href = element.getAttribute("href");

0 commit comments

Comments
 (0)