-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use defined prettier settings to lint content_script.ts file.
- Loading branch information
Showing
1 changed file
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
function init() { | ||
chrome.runtime.sendMessage('trigger', (response) => { | ||
console.log('Skip intro button:', response); | ||
addSkipButton(response); | ||
}); | ||
chrome.runtime.sendMessage('trigger', response => { | ||
console.log('Skip intro button:', response) | ||
addSkipButton(response) | ||
}) | ||
} | ||
|
||
function styleButton(button: HTMLDivElement) { | ||
button.style.zIndex = '999'; | ||
button.style.color = 'white'; | ||
button.style.position = 'fixed'; | ||
button.style.right = '0'; | ||
button.style.bottom = '80px'; | ||
button.style.zIndex = '999' | ||
button.style.color = 'white' | ||
button.style.position = 'fixed' | ||
button.style.right = '0' | ||
button.style.bottom = '80px' | ||
|
||
button.style.backgroundColor = 'rgba(0,0,0,0.3)'; | ||
button.style.border = '1px solid white'; | ||
button.style.padding = '10px 10px 9px 10px'; | ||
button.style.margin = '0 20px 0 0'; | ||
button.style.fontSize = '16px'; | ||
button.style.cursor = 'pointer'; | ||
button.style.display = 'none'; | ||
button.id = 'skipButton'; | ||
button.style.backgroundColor = 'rgba(0,0,0,0.3)' | ||
button.style.border = '1px solid white' | ||
button.style.padding = '10px 10px 9px 10px' | ||
button.style.margin = '0 20px 0 0' | ||
button.style.fontSize = '16px' | ||
button.style.cursor = 'pointer' | ||
button.style.display = 'none' | ||
button.id = 'skipButton' | ||
} | ||
|
||
function addSkipButton(resp: any) { | ||
let root = document.getElementById('vilosRoot'); | ||
let root = document.getElementById('vilosRoot') | ||
if (!root) { | ||
return; | ||
return | ||
} | ||
|
||
let player: any = document.getElementById('player0'); | ||
let player: any = document.getElementById('player0') | ||
|
||
let button = document.createElement('div'); | ||
styleButton(button); | ||
button.innerHTML = `SKIP INTRO<br/>${resp.text}`; | ||
let button = document.createElement('div') | ||
styleButton(button) | ||
button.innerHTML = `SKIP INTRO<br/>${resp.text}` | ||
|
||
button.onclick = () => { | ||
player.currentTime = resp.interval; | ||
}; | ||
root.append(button); | ||
window.setInterval(showHideSkipButton(resp.interval), 1000); | ||
player.currentTime = resp.interval | ||
} | ||
|
||
root.append(button) | ||
window.setInterval(toggleSkipButton(resp.interval), 1000) | ||
} | ||
|
||
function showHideSkipButton(ts: number) { | ||
let intro = ts; | ||
let skipButton = document.getElementById('skipButton'); | ||
let player = document.getElementById('player0'); | ||
function toggleSkipButton(ts: number) { | ||
let intro = ts | ||
let skipButton = document.getElementById('skipButton') | ||
let player: any = document.getElementById('player0') | ||
|
||
return function () { | ||
if (!skipButton || !player) { | ||
return; | ||
return | ||
} | ||
|
||
let time = parseInt((<any>player).currentTime); | ||
let time = parseInt(player.currentTime) | ||
if (time < intro) { | ||
skipButton.style.display = 'block'; | ||
skipButton.style.display = 'block' | ||
} else { | ||
skipButton.style.display = 'none'; | ||
skipButton.style.display = 'none' | ||
} | ||
}; | ||
} | ||
} | ||
|
||
init(); | ||
init() |