1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
28b9b9b9e8 Version 3.0. Fix for minor data format change.
Signed-off-by: Daniel Perelman <perelman@cs.washington.edu>
2024-05-25 00:55:03 -07:00
b7aec81ff0 Apply loading fix to Firefox codepath, too. 2024-05-22 19:26:37 -07:00

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Folklife 2024 schedule fixes
// @namespace http://tampermonkey.net/
// @version 2.0
// @version 3.0
// @description Show schedule as a grid.
// @author Daniel Perelman (perelman@aweirdimagination.net)
// @match https://app.nwfolklife.org/embeddable/events/2/schedule
@ -19,11 +19,27 @@
const w = window.wrappedJSObject || window;
if (window.wrappedJSObject) {
const ourSetData = json => {
if (!data) data = [];
data.push(...JSON.parse(json).data.blocks);
const ourSetData = json => {
if (!data) data = [];
const newData = JSON.parse(json).data;
const newBlocks = newData.blocks;
if (newBlocks) data.push(...newBlocks);
const newVenues = newData.venues;
if (newVenues) {
// To avoid rewriting the code below, just rewrite into list of blocks.
for (const venue of newVenues) {
const name = venue.name
const blocks = venue.blocks
for (const b of blocks) {
b.venue = { name }
}
data.push(...blocks)
}
}
}
if (window.wrappedJSObject) {
exportFunction(ourSetData, window, { defineAs: "shareDataWithFixes" })
w.eval("window.originalFetch = window.fetch")
@ -47,9 +63,7 @@
const response = await originalFetch(resource, config);
// response interceptor here
if (!data) data = [];
const newData = (await response.clone().json()).data
const newBlocks = newData.blocks
if (newBlocks) data.push(...newBlocks);
ourSetData(await response.clone().text());
return response;
};
}