1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { dataToRSS } from "https://esm.town/v/Glench/dataToRSS";
import { fetch } from "https://esm.town/v/std/fetch";
async function getOfficialRedditPosts() {
const resp = await fetch("https://www.reddit.com/r/googlephotos/.json");
if (!resp.ok) return [];
const json = await resp.json();
const filtered_posts = json.data.children.filter(x => {
const title = x.data.title.toLowerCase();
return title.includes("delet") || title.includes("remov") || title.includes("free");
});
return filtered_posts;
}
async function getGoogleSupportForumPosts() {
const resp = await fetch(
"https://support.google.com/photos/threads?hl=en&max_results=500",
);
const text = await resp.text();
// looking for " <a class="thread-list-thread" data-stats-id="247061455" data-stats-ve="87" href="/photos/thread/247061455/how-know-my-photo-record-deleted?hl=en" aria-label=" thread titled How know my photo record deleted FIX_PROBLEM Yas 0 Replies
const [_, ...threads_text] = text.split(/class="thread-list-thread"/);
return threads_text.map(x => {
const id = x.match(/\d+/)[0];
const url = `https://support.google.com${x.split("href=\"")[1].split("\"")[0]}`;
const title = x.split("thread-list-thread__title\">")[1].split("<span")[0].trim() + " (Google Support Forum)";
const selfText = x.split("\"thread-list-thread__snippet\">")[1].split("</span>")[0];
return { data: { created: id, url, title, selfText } };
}).filter(thread_obj => {
const title = thread_obj.data.title.toLowerCase();
return title.includes("delet") && !(
title.includes("recover")
|| title.includes("restor")
|| title.includes("perma")
|| title.includes("trash")
|| title.includes("back")
|| title.includes("deleted")
|| title.includes("mistak")
);
});
}
export const googlePhotosMarketingRSS = async (x) => {
const reddit_posts = await getOfficialRedditPosts();
const google_forum_posts = []; // await getGoogleSupportForumPosts(); // no signal anymore
return new Response(dataToRSS([...reddit_posts, ...google_forum_posts], {
title: "Delete All Google Photos Marketing RSS",
description:
"For marketing Delete All Google Photos Extension. Scrapes r/GooglePhotos and Google's official support forum.",
link: "https://www.reddit.com/r/googlephotos/",
item: {
title: x => x.data.title,
description: x => x.data.selfText,
link: x => x.data.url,
pubDate: x => x.data.created,
},
}));
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.