Skip to content

Instantly share code, notes, and snippets.

@insin
Created May 24, 2025 06:31
Show Gist options
  • Save insin/351bf2344d340090677e23c1166ffd1a to your computer and use it in GitHub Desktop.
Save insin/351bf2344d340090677e23c1166ffd1a to your computer and use it in GitHub Desktop.
Going from "I am so S.M.R.T!" to "how have I been so stupid?" just like that
window.fetch = new Proxy(window.fetch, {
apply(target, thisArg, argArray) {
let promise = Reflect.apply(target, thisArg, argArray)
let url = argArray[0] instanceof Request ? argArray[0].url : argArray[0]
if (url.includes('reel_item_watch')) {
console.log('intercepting reel_item_watch')
return promise.then(response => {
response.clone().json().then(json => {
let menuItems = json.overlay.reelPlayerOverlayRenderer.menu.menuRenderer.items
let openAppItem = menuItems.find(item =>
item.menuNavigationItemRenderer?.icon.iconType == 'OPEN_IN_NEW'
)
console.log({
[document.body?.lang]: openAppItem.menuNavigationItemRenderer.text.runs[0].text,
})
}).catch(e => {
console.log('error getting JSON', e)
})
return response
})
}
return promise
}
})
window.fetch = new Proxy(window.fetch, {
apply(target, thisArg, argArray) {
let promise = Reflect.apply(target, thisArg, argArray)
let url = argArray[0] instanceof Request ? argArray[0].url : argArray[0]
if (url.includes('reel_item_watch')) {
return promise.then(response => {
return response.clone().json().then(json => {
let menuItems = json.overlay.reelPlayerOverlayRenderer.menu.menuRenderer.items
let openAppItemIndex = menuItems.findIndex(
item => item.menuNavigationItemRenderer?.icon.iconType == 'OPEN_IN_NEW'
)
if (openAppItemIndex != -1) menuItems.splice(openAppItemIndex, 1)
return new Response(JSON.stringify(json), {
status: response.status,
statusText: response.statusText,
headers: response.headers,
})
}).catch(() => response)
}).catch(() => promise)
}
return promise
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment