mirror of
https://github.com/streamwall/streamwall.git
synced 2026-04-03 20:32:08 -04:00
Remove defunct iframe and igHacks code
This commit is contained in:
@@ -21,7 +21,7 @@ const VIDEO_OVERRIDE_STYLE = `
|
|||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
video, iframe.__video__, audio, body:after {
|
video, audio, body:after {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
position: absolute !important;
|
position: absolute !important;
|
||||||
top: 0 !important;
|
top: 0 !important;
|
||||||
@@ -36,10 +36,6 @@ const VIDEO_OVERRIDE_STYLE = `
|
|||||||
audio {
|
audio {
|
||||||
z-index: 999998 !important;
|
z-index: 999998 !important;
|
||||||
}
|
}
|
||||||
/* deprecate? */
|
|
||||||
.__video_parent__ {
|
|
||||||
display: block !important;
|
|
||||||
}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const WEB_OVERRIDE_STYLE = `
|
const WEB_OVERRIDE_STYLE = `
|
||||||
@@ -242,7 +238,6 @@ async function waitForVideo(
|
|||||||
timeoutMs = INITIAL_TIMEOUT,
|
timeoutMs = INITIAL_TIMEOUT,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
video?: HTMLMediaElement
|
video?: HTMLMediaElement
|
||||||
iframe?: HTMLIFrameElement
|
|
||||||
}> {
|
}> {
|
||||||
lockdownMediaTags()
|
lockdownMediaTags()
|
||||||
|
|
||||||
@@ -250,67 +245,23 @@ async function waitForVideo(
|
|||||||
if (timeoutMs !== Infinity) {
|
if (timeoutMs !== Infinity) {
|
||||||
queryPromise = Promise.race([queryPromise, sleep(timeoutMs)])
|
queryPromise = Promise.race([queryPromise, sleep(timeoutMs)])
|
||||||
}
|
}
|
||||||
let video: Element | null | void = await queryPromise
|
const video: Element | null | void = await queryPromise
|
||||||
if (video instanceof HTMLMediaElement) {
|
if (video instanceof HTMLMediaElement) {
|
||||||
return { video }
|
return { video }
|
||||||
}
|
}
|
||||||
|
|
||||||
let iframe
|
|
||||||
for (iframe of document.querySelectorAll('iframe')) {
|
|
||||||
video = iframe.contentDocument?.querySelector?.(kind)
|
|
||||||
if (video instanceof HTMLVideoElement) {
|
|
||||||
return { video, iframe }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const igHacks = {
|
|
||||||
isMatch() {
|
|
||||||
return location.host === 'www.instagram.com'
|
|
||||||
},
|
|
||||||
async onLoad() {
|
|
||||||
const playButton = await Promise.race([
|
|
||||||
waitForQuery('button'),
|
|
||||||
waitForQuery('video'),
|
|
||||||
sleep(1000),
|
|
||||||
])
|
|
||||||
if (
|
|
||||||
playButton instanceof HTMLButtonElement &&
|
|
||||||
playButton.tagName === 'BUTTON' &&
|
|
||||||
playButton.textContent === 'Tap to play'
|
|
||||||
) {
|
|
||||||
playButton.click()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
async function findMedia(
|
async function findMedia(
|
||||||
kind: 'video' | 'audio',
|
kind: 'video' | 'audio',
|
||||||
elementTimeout = INITIAL_TIMEOUT,
|
elementTimeout = INITIAL_TIMEOUT,
|
||||||
) {
|
) {
|
||||||
if (igHacks.isMatch()) {
|
const { video } = await waitForVideo(kind, elementTimeout)
|
||||||
await igHacks.onLoad()
|
|
||||||
}
|
|
||||||
|
|
||||||
const { video, iframe } = await waitForVideo(kind, elementTimeout)
|
|
||||||
if (!video) {
|
if (!video) {
|
||||||
throw new Error('could not find video')
|
throw new Error('could not find video')
|
||||||
}
|
}
|
||||||
if (iframe && iframe.contentDocument) {
|
document.body.appendChild(video)
|
||||||
const style = iframe.contentDocument.createElement('style')
|
|
||||||
style.innerHTML = VIDEO_OVERRIDE_STYLE
|
|
||||||
iframe.contentDocument.head.appendChild(style)
|
|
||||||
iframe.className = '__video__'
|
|
||||||
let parentEl = iframe.parentElement
|
|
||||||
while (parentEl) {
|
|
||||||
parentEl.className = '__video_parent__'
|
|
||||||
parentEl = parentEl.parentElement
|
|
||||||
}
|
|
||||||
iframe.contentDocument.body.appendChild(video)
|
|
||||||
} else {
|
|
||||||
document.body.appendChild(video)
|
|
||||||
}
|
|
||||||
|
|
||||||
video.play()
|
video.play()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user