1
0

Compare commits

..

No commits in common. "28b9b9b9e80f521379106ae6af40e62b6a5150d3" and "8c4b8c97a1789a076deb0b91aedd1f52e6e821a4" have entirely different histories.

View File

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