Skip to content

Commit

Permalink
Lint content script file
Browse files Browse the repository at this point in the history
Use defined prettier settings to lint content_script.ts file.
  • Loading branch information
rquitales committed Apr 5, 2021
1 parent 7348bbb commit 8e00437
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/content_script.ts
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()

0 comments on commit 8e00437

Please sign in to comment.