auto-fix lint

pull/12/head
Kevin Gibbons 1 year ago
parent 64d29b5a4f
commit ee7da0e726

@ -68,7 +68,7 @@ async function sendData(path, payload, method) {
// read access details from storage.local // read access details from storage.local
async function getAccess() { async function getAccess() {
var storage = await browserType.storage.local.get('access'); let storage = await browserType.storage.local.get('access');
return storage.access; return storage.access;
} }
@ -148,14 +148,14 @@ async function sendCookies() {
console.log('function sendCookies'); console.log('function sendCookies');
let cookieStores = await browserType.cookies.getAllCookieStores(); let cookieStores = await browserType.cookies.getAllCookieStores();
var cookieLines = [ let cookieLines = [
'# Netscape HTTP Cookie File', '# Netscape HTTP Cookie File',
'# https://curl.haxx.se/rfc/cookie_spec.html', '# https://curl.haxx.se/rfc/cookie_spec.html',
'# This is a generated file! Do not edit.\n', '# This is a generated file! Do not edit.\n',
]; ];
for (let i = 0; i < cookieStores.length; i++) { for (let i = 0; i < cookieStores.length; i++) {
const cookieStore = cookieStores[i]; const cookieStore = cookieStores[i];
var allCookiesStore = await browserType.cookies.getAll({ let allCookiesStore = await browserType.cookies.getAll({
domain: '.youtube.com', domain: '.youtube.com',
storeId: cookieStore['id'], storeId: cookieStore['id'],
}); });

@ -102,7 +102,7 @@ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="pres
</svg>`; </svg>`;
function buildButtonDiv() { function buildButtonDiv() {
var buttonDiv = document.createElement('div'); let buttonDiv = document.createElement('div');
buttonDiv.setAttribute('id', 'ta-channel-button'); buttonDiv.setAttribute('id', 'ta-channel-button');
Object.assign(buttonDiv.style, { Object.assign(buttonDiv.style, {
@ -119,18 +119,18 @@ function buildButtonDiv() {
} }
function buildSubLink(channelContainer) { function buildSubLink(channelContainer) {
var subLink = document.createElement('span'); let subLink = document.createElement('span');
subLink.innerText = 'Subscribe'; subLink.innerText = 'Subscribe';
subLink.addEventListener('click', e => { subLink.addEventListener('click', e => {
e.preventDefault(); e.preventDefault();
var currentLocation = window.location.href; let currentLocation = window.location.href;
console.log('subscribe to: ' + currentLocation); console.log('subscribe to: ' + currentLocation);
sendUrl(currentLocation, 'subscribe', subLink); sendUrl(currentLocation, 'subscribe', subLink);
}); });
subLink.addEventListener('mouseover', e => { subLink.addEventListener('mouseover', e => {
let subText; let subText;
if (window.location.pathname == '/watch') { if (window.location.pathname == '/watch') {
var currentLocation = window.location.href; let currentLocation = window.location.href;
subText = currentLocation; subText = currentLocation;
} else { } else {
subText = channelContainer.querySelector('#text').textContent; subText = channelContainer.querySelector('#text').textContent;
@ -147,26 +147,26 @@ function buildSubLink(channelContainer) {
} }
function buildSpacer() { function buildSpacer() {
var spacer = document.createElement('span'); let spacer = document.createElement('span');
spacer.innerText = '|'; spacer.innerText = '|';
return spacer; return spacer;
} }
function buildDlLink(channelContainer) { function buildDlLink(channelContainer) {
var dlLink = document.createElement('span'); let dlLink = document.createElement('span');
dlLink.innerHTML = downloadIcon; dlLink.innerHTML = downloadIcon;
dlLink.addEventListener('click', e => { dlLink.addEventListener('click', e => {
e.preventDefault(); e.preventDefault();
var currentLocation = window.location.href; let currentLocation = window.location.href;
console.log('download: ' + currentLocation); console.log('download: ' + currentLocation);
sendUrl(currentLocation, 'download', dlLink); sendUrl(currentLocation, 'download', dlLink);
}); });
dlLink.addEventListener('mouseover', e => { dlLink.addEventListener('mouseover', e => {
let subText; let subText;
if (window.location.pathname == '/watch') { if (window.location.pathname == '/watch') {
var currentLocation = window.location.href; let currentLocation = window.location.href;
subText = currentLocation; subText = currentLocation;
} else { } else {
subText = channelContainer.querySelector('#text').textContent; subText = channelContainer.querySelector('#text').textContent;
@ -185,36 +185,36 @@ function buildDlLink(channelContainer) {
} }
function buildChannelButton(channelContainer) { function buildChannelButton(channelContainer) {
var buttonDiv = buildButtonDiv(); let buttonDiv = buildButtonDiv();
var subLink = buildSubLink(channelContainer); let subLink = buildSubLink(channelContainer);
buttonDiv.appendChild(subLink); buttonDiv.appendChild(subLink);
var spacer = buildSpacer(); let spacer = buildSpacer();
buttonDiv.appendChild(spacer); buttonDiv.appendChild(spacer);
var dlLink = buildDlLink(channelContainer); let dlLink = buildDlLink(channelContainer);
buttonDiv.appendChild(dlLink); buttonDiv.appendChild(dlLink);
return buttonDiv; return buttonDiv;
} }
function getChannelContainers() { function getChannelContainers() {
var nodes = document.querySelectorAll('#inner-header-container, #owner'); let nodes = document.querySelectorAll('#inner-header-container, #owner');
return nodes; return nodes;
} }
function getThubnailContainers() { function getThubnailContainers() {
var nodes = document.querySelectorAll('#thumbnail'); let nodes = document.querySelectorAll('#thumbnail');
return nodes; return nodes;
} }
function buildVideoButton(thumbContainer) { function buildVideoButton(thumbContainer) {
var thumbLink = thumbContainer?.href; let thumbLink = thumbContainer?.href;
if (!thumbLink) return; if (!thumbLink) return;
if (thumbLink.includes('list=') || thumbLink.includes('/shorts/')) return; if (thumbLink.includes('list=') || thumbLink.includes('/shorts/')) return;
var dlButton = document.createElement('a'); let dlButton = document.createElement('a');
dlButton.setAttribute('id', 'ta-video-button'); dlButton.setAttribute('id', 'ta-video-button');
dlButton.href = '#'; dlButton.href = '#';
@ -253,7 +253,7 @@ function buildVideoButton(thumbContainer) {
transition: 'all 0.3s ease 0.3s', transition: 'all 0.3s ease 0.3s',
}); });
var dlIcon = document.createElement('span'); let dlIcon = document.createElement('span');
dlIcon.innerHTML = downloadIcon; dlIcon.innerHTML = downloadIcon;
Object.assign(dlIcon.style, { Object.assign(dlIcon.style, {
filter: 'invert()', filter: 'invert()',
@ -290,21 +290,21 @@ function adjustOwner(channelContainer) {
} }
function ensureTALinks() { function ensureTALinks() {
var channelContainerNodes = getChannelContainers(); let channelContainerNodes = getChannelContainers();
for (var channelContainer of channelContainerNodes) { for (let channelContainer of channelContainerNodes) {
channelContainer = adjustOwner(channelContainer); channelContainer = adjustOwner(channelContainer);
if (channelContainer.hasTA) continue; if (channelContainer.hasTA) continue;
var channelButton = buildChannelButton(channelContainer); let channelButton = buildChannelButton(channelContainer);
channelContainer.appendChild(channelButton); channelContainer.appendChild(channelButton);
channelContainer.hasTA = true; channelContainer.hasTA = true;
} }
var thumbContainerNodes = getThubnailContainers(); let thumbContainerNodes = getThubnailContainers();
for (var thumbContainer of thumbContainerNodes) { for (let thumbContainer of thumbContainerNodes) {
if (thumbContainer.hasTA) continue; if (thumbContainer.hasTA) continue;
var videoButton = buildVideoButton(thumbContainer); let videoButton = buildVideoButton(thumbContainer);
if (videoButton == null) continue; if (videoButton == null) continue;
thumbContainer.parentElement.appendChild(videoButton); thumbContainer.parentElement.appendChild(videoButton);
thumbContainer.hasTA = true; thumbContainer.hasTA = true;

Loading…
Cancel
Save