Compare commits
2 Commits
8c4b8c97a1
...
28b9b9b9e8
Author | SHA1 | Date | |
---|---|---|---|
28b9b9b9e8 | |||
b7aec81ff0 |
|
@ -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 2.0
|
// @version 3.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,11 +19,27 @@
|
||||||
|
|
||||||
const w = window.wrappedJSObject || window;
|
const w = window.wrappedJSObject || window;
|
||||||
|
|
||||||
if (window.wrappedJSObject) {
|
|
||||||
const ourSetData = json => {
|
const ourSetData = json => {
|
||||||
if (!data) data = [];
|
if (!data) data = [];
|
||||||
data.push(...JSON.parse(json).data.blocks);
|
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" })
|
exportFunction(ourSetData, window, { defineAs: "shareDataWithFixes" })
|
||||||
w.eval("window.originalFetch = window.fetch")
|
w.eval("window.originalFetch = window.fetch")
|
||||||
|
@ -47,9 +63,7 @@
|
||||||
const response = await originalFetch(resource, config);
|
const response = await originalFetch(resource, config);
|
||||||
// response interceptor here
|
// response interceptor here
|
||||||
if (!data) data = [];
|
if (!data) data = [];
|
||||||
const newData = (await response.clone().json()).data
|
ourSetData(await response.clone().text());
|
||||||
const newBlocks = newData.blocks
|
|
||||||
if (newBlocks) data.push(...newBlocks);
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user