|
// ==UserScript== |
|
// @name Mock fetch |
|
// @namespace http://tampermonkey.net/ |
|
// @version 2026-07-29 |
|
// @description try to take over the world! |
|
// @author You |
|
// @match https://wheelofnames.com/* |
|
// @run-at document-start |
|
// ==/UserScript== |
|
|
|
console.log('Hi from TamperMoonkey'); |
|
|
|
console.log("TM fetch:", window.fetch); |
|
console.log("Page fetch:", unsafeWindow.fetch); |
|
|
|
(() => { |
|
'use strict'; |
|
var mockResponse = { |
|
"data": { |
|
"title": "some team", |
|
"description": "", |
|
"shareMode": "copyable", |
|
"wheelConfigs": [ |
|
{ |
|
"afterSpinSound": "applause-sound-soft", |
|
"afterSpinSoundVolume": 50, |
|
"allowDuplicates": true, |
|
"animateWinner": false, |
|
"autoRemoveWinner": false, |
|
"centerText": "", |
|
"colorSettings": [ |
|
{ |
|
"color": "#f4ce13", |
|
"enabled": true |
|
}, |
|
{ |
|
"color": "#ffffff", |
|
"enabled": true |
|
}, |
|
{ |
|
"color": "#000000", |
|
"enabled": false |
|
}, |
|
{ |
|
"color": "#000000", |
|
"enabled": false |
|
}, |
|
{ |
|
"color": "#000000", |
|
"enabled": false |
|
}, |
|
{ |
|
"color": "#000000", |
|
"enabled": false |
|
} |
|
], |
|
"coverImageName": "", |
|
"coverImageType": "", |
|
"customCoverImageDataUri": "", |
|
"customPictureDataUri": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gHY/2wBDA/2wBDA/wAA/8Q//EADM/8QAG/EAC8R/2gAM/AP0/Dvr+PU+2OI+2OI+3O+3/any/v+GFu7U+X9/wAMLnNu/Iq9v+Dj/Y2+1X/TbdF/wDr/ZVmma/tT5f3/DC3dqfL+/4YXObd+RV+ML+wRdAAAA//Z", // dummy value |
|
"customPictureName": "somelogo.png", |
|
"description": "", |
|
"displayHideButton": true, |
|
"displayRemoveButton": true, |
|
"displayWinnerDialog": true, |
|
"drawOutlines": false, |
|
"drawShadow": true, |
|
"duringSpinSound": "ticking-sound", |
|
"duringSpinSoundVolume": 50, |
|
"entries": [ |
|
{ |
|
"text": "A", |
|
"weight": 1, |
|
"enabled": true |
|
}, |
|
{ |
|
"text": "B", |
|
"weight": 1, |
|
"enabled": true |
|
}, |
|
{ |
|
"text": "C", |
|
"weight": 1, |
|
"enabled": true |
|
}, |
|
{ |
|
"text": "D", |
|
"weight": 1, |
|
"enabled": true, |
|
"color": "#7f7f7f" |
|
}, |
|
{ |
|
"text": "E", |
|
"weight": 1, |
|
"enabled": true |
|
}, |
|
{ |
|
"text": "Jawad", |
|
"weight": 0, |
|
"enabled": true |
|
}, |
|
{ |
|
"text": "F", |
|
"weight": 1, |
|
"enabled": true, |
|
"color": "#666666" |
|
} |
|
], |
|
"galleryPicture": "/images/none.png", |
|
"hubSize": "L", |
|
"isAdvanced": true, |
|
"launchConfetti": true, |
|
"maxNames": 1000, |
|
"pageBackgroundColor": "#FFFFFF", |
|
"pictureType": "uploaded", |
|
"playClickWhenWinnerRemoved": false, |
|
"showTitle": true, |
|
"slowSpin": false, |
|
"spinTime": 10, |
|
"title": "OG Squad", |
|
"type": "color", |
|
"winnerMessage": "", |
|
"pointerChangesColor": true, |
|
"pageGradient": true, |
|
"font": "" |
|
} |
|
], |
|
"path": "hm5-cq4", |
|
"created": 1770194440600, |
|
"lastWrite": 1770194617982, |
|
"readCount": 118, |
|
"lastRead": 1785333782360 |
|
} |
|
} |
|
|
|
console.debug("Hi, the snippet is running!"); |
|
const originalFetch = unsafeWindow.fetch; |
|
console.debug("After Originals"); |
|
|
|
unsafeWindow.fetch = async (input, init) => { |
|
console.debug("Inside mocked fetch"); |
|
const url = typeof input === "string" ? input : input.url; |
|
console.debug('url is ' + url); |
|
if (url.includes("/api/v3/wheels/")) { |
|
console.debug("Returning mocked response"); |
|
|
|
return new Response( |
|
JSON.stringify(mockResponse), |
|
{ status: 200, headers: { "Content-Type": "application/json" } } |
|
); |
|
} |
|
|
|
return originalFetch(input, init); |
|
}; |
|
})() |