PageSourceSearch

https://corkiejp.github.io/ATProtoViewer/service-worker.js

js corkiejp.github.io collected 2026-10-03 08:49:57 UTC 5,154 bytes, 124 lines download raw bytes

1const CACHE_NAME = 'atproto-pwa-v1.37';
2const URLS_TO_CACHE = [
3  '/ATProtoViewer/',
4  '/ATProtoViewer/index.html',
5  '/ATProtoViewer/BlueskyPostViewer.html',
6  '/ATProtoViewer/Blueskyessentiallinks.html',
7  '/ATProtoViewer/ATProtoSimpleFeeds.html',
8  '/ATProtoViewer/bookmarks.html',
9  '/ATProtoViewer/manifest.webmanifest',
10  '/ATProtoViewer/styles.css',
11  '/ATProtoViewer/main.js',
12  '/ATProtoViewer/assets/icon-192.png',
13  '/ATProtoViewer/assets/icon-512.png'
14];
15
16
17// Localstorage Bookmarks + autofill for desc! Fixed a bug that stopped scrolling on modal close.
18// More list now in a modal display instead of drop down.
19// Modal window to show bookmarks, with link to bookmarks page to manage them. v2
20// Display follow records.
21// Handle should now be displayed instead of DID string.
22// Set your own presets and import/export them + display of likes.
23// Update of CSS for mobile display ~ Didn't work had to resort to old form layout!
24// And forgot about the likes option!
25// Added to instructions for presets.
26// Added lists display. + Linkto toolify.blue added.
27// Added a simple feed/list viewer + a small edit to display handle on single posts + search for feeds instructions.
28// Integrated a view button on my lists display.
29// Bug fixes on feed/list viewer and addition of bskyinfo.com to links list.
30// Listed with bskyinfo, added a badge to the page. (3)
31// Lists/Feeds display title when available. (2)
32// Added a link to https://atproto.at/viewer for records/did + added to list of links.
33// Updated hopefully to handle profile shares? Due to bluesky updates on the 5th June.
34// Added support for iOS hopefully? safari-26
35// https://developer.apple.com/documentation/safari-release-notes/safari-26-release-notes#Web-Apps
36// Hope this latest change will detect feed shares? & List Feeds. (4)
37// Changed Icon. and changed back!
38// Added Button link to BlueskToMP4.com video downloader.
39// Updated the essential links with the above.
40// Trying a different icon again
41// Added a QR code to my page! + Deletion of unused function.
42// Link to ttospwa which has additional links.
43// Bluesky Embeds modal popup integrated. Thanks to @baileytownsend.dev resolving a bug with a single line of code.
44// Bug fixes from previous commit. + also on the simple feeds viewer now (2)
45// Feeds embed modal and some style on record at uri so it wraps! + Recent feeds/list remembered
46// Added RedDwarfLIte link
47// Hopefully at a protocol 'web+at' for this PWA.
48// Added links to https://scrapboard.org/ for accounts images posts. + Profile links when active in more menu. (3)
49// Prep for EU age verification. + Disclaimer
50// Change example feeds provided! ~ Age gated through YouTube short NSFW 18+ (3) ~ New code 2207
51// Redditors example feed added
52// Switch from youtube video to bluesky post for age gate code!
53// Install: Pre-cache assets
54self.addEventListener('install', event => {
55  event.waitUntil(
56    caches.open(CACHE_NAME).then(cache => cache.addAll(URLS_TO_CACHE))
57  );
58  self.skipWaiting();
59});
60
61// Activate: Clean up old caches
62self.addEventListener('activate', event => {
63  event.waitUntil(
64    caches.keys().then(cacheNames =>
65      Promise.all(
66        cacheNames
67          .filter(cacheName => cacheName !== CACHE_NAME)
68          .map(cacheName => caches.delete(cacheName))
69      )
70    ).then(() => self.clients.claim())
71     .then(() => {
72        // Notify all clients that SW is activated
73        return self.clients.matchAll().then(clients => {
74          clients.forEach(client => {
75            client.postMessage({type: 'SW_ACTIVATED'});
76          });
77        });
78      })
79  );
80});
81
82// Fetch: Handle redirects and serve cache/network
83self.addEventListener('fetch', event => {
84  const url = new URL(event.request.url);
85
86  // Handle share redirect to /ATProtoViewer/
87  if (url.pathname === '/ATProtoViewer/') {
88    const sharedData = url.searchParams.get('uri') ||
89                       url.searchParams.get('text') ||
90                       url.searchParams.get('url');
91
92    let redirectUrl = '/ATProtoViewer/index.html'; // Default
93
94    if (sharedData) {
95      // 1. Check for Bluesky feed URL
96      const isFeed = /^https:\/\/bsky\.app\/profile\/([^/]+)\/feed\/([^/]+)/.test(sharedData);
97      // 2. Check for Bluesky list URL
98      const isList = /^https:\/\/bsky\.app\/profile\/([^/]+)\/lists?\/([^/]+)/.test(sharedData);
99
100      if (isFeed) {
101        // Redirect to feed viewer
102        redirectUrl = `/ATProtoViewer/ATProtoSimpleFeeds.html?input=${encodeURIComponent(sharedData)}`;
103      } else if (isList) {
104        // Redirect to list viewer (you may need to create this page)
105        redirectUrl = `/ATProtoViewer/ATProtoSimpleFeeds.html?input=${encodeURIComponent(sharedData)}`;
106      } else if (sharedData.startsWith('did:')) {
107        redirectUrl += `?did=${encodeURIComponent(sharedData)}`;
108      } else {
109        redirectUrl += `?uri=${encodeURIComponent(sharedData)}`;
110      }
111    }
112
113    event.respondWith(Response.redirect(redirectUrl, 302));
114    return;
115  }
116
117  // Default: serve from cache, then network
118  event.respondWith(
119    caches.match(event.request).then(response => response || fetch(event.request))
120  );
121});
122
123
124

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.