Skip to content

Commit

Permalink
Fixed code indent
Browse files Browse the repository at this point in the history
  • Loading branch information
dodieboy committed Jul 3, 2024
1 parent 8907f0f commit 39658f7
Show file tree
Hide file tree
Showing 24 changed files with 1,686 additions and 1,694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/js-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: npm install

- name: Install dependencies
- name: Run eslint
run: npx eslint

- name: Run JSLint
Expand Down
122 changes: 61 additions & 61 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,38 +253,38 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
//console.log(sender);

switch(message.action || message.name || message) {
case 'play':
tabPrune(function () {
for (let id in tabConnected) {
id = Number(id);
if (id != sender.tab.id) {
chrome.tabs.sendMessage(id, {action: "another-video-started-playing"});
}
case 'play':
tabPrune(function () {
for (let id in tabConnected) {
id = Number(id);
if (id != sender.tab.id) {
chrome.tabs.sendMessage(id, {action: "another-video-started-playing"});
}
});
break
}
});
break

case 'options-page-connected':
sendResponse({
isTab: sender.hasOwnProperty('tab')
});
break
case 'options-page-connected':
sendResponse({
isTab: sender.hasOwnProperty('tab')
});
break

case 'tab-connected':
tabConnected[sender.tab.id] = true;
sendResponse({
tabId: sender.tab.id
});
break
case 'tab-connected':
tabConnected[sender.tab.id] = true;
sendResponse({
tabId: sender.tab.id
});
break

case 'fixPopup':
//~ get the current focused tab and convert it to a URL-less popup (with same state and size)
chrome.windows.getLastFocused(w => {
chrome.tabs.query({
windowId: w.id,
active: true
}, ts => {
const tID = ts[0]?.id,
case 'fixPopup':
//~ get the current focused tab and convert it to a URL-less popup (with same state and size)
chrome.windows.getLastFocused(w => {
chrome.tabs.query({
windowId: w.id,
active: true
}, ts => {
const tID = ts[0]?.id,
data = { type: 'popup',
state: w.state,
width: parseInt(message.width, 10),
Expand All @@ -293,42 +293,42 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
top: 20
}

if (tID) {data.tabId = tID;}
chrome.windows.create(data, pw => {});
if (tID) {data.tabId = tID;}
chrome.windows.create(data, pw => {});

//append to title?
chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo) {
if (tabId === tID && changeInfo.status === 'complete' && !message.title.startsWith("undefined")) {
chrome.tabs.onUpdated.removeListener(listener);
chrome.scripting.executeScript({ target: { tabId: tID }, func: () => { document.title = `${message.title} - ImprovedTube`; } }); //manifest3
// chrome.tabs.executeScript(tID, {code: `document.title = "${message.title} - ImprovedTube";`}); //manifest2
}
});
//append to title?
chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo) {
if (tabId === tID && changeInfo.status === 'complete' && !message.title.startsWith("undefined")) {
chrome.tabs.onUpdated.removeListener(listener);
chrome.scripting.executeScript({ target: { tabId: tID }, func: () => { document.title = `${message.title} - ImprovedTube`; } }); //manifest3
// chrome.tabs.executeScript(tID, {code: `document.title = "${message.title} - ImprovedTube";`}); //manifest2
}
});
});
break
case 'download':
chrome.permissions.request({
permissions: ['downloads'],
origins: ['https://www.youtube.com/*']
}, function (granted) {
if (granted) {
try {
var blob = new Blob([JSON.stringify(message.value)], {
type: 'application/json;charset=utf-8'
});
chrome.downloads.download({
url: URL.createObjectURL(blob),
filename: message.filename,
saveAs: true
});
} catch (error) {
console.error(error);
}
} else {
console.error('Permission is not granted.');
}})
break
});
break
case 'download':
chrome.permissions.request({
permissions: ['downloads'],
origins: ['https://www.youtube.com/*']
}, function (granted) {
if (granted) {
try {
var blob = new Blob([JSON.stringify(message.value)], {
type: 'application/json;charset=utf-8'
});
chrome.downloads.download({
url: URL.createObjectURL(blob),
filename: message.filename,
saveAs: true
});
} catch (error) {
console.error(error);
}
} else {
console.error('Permission is not granted.');
}})
break
}
});
/*-----# UNINSTALL URL-----------------------------------*/
Expand Down
10 changes: 1 addition & 9 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ export default [...compat.extends("eslint:recommended"), {
...globals.webextensions,
...globals.jest,
...globals.worker,
...globals.wsh,
"ImprovedTube" : false,
"satus": false,
"extension": false,
"loading": false,
"vertical": false,
"shorts": false,
"DATA": false,
"keywords": false
...globals.wsh
},
},
rules: {
Expand Down
12 changes: 6 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
testPathIgnorePatterns: [
"/node_modules/"
],
testMatch: [
"**/tests/**/*.js"
]
testPathIgnorePatterns: [
"/node_modules/"
],
testMatch: [
"**/tests/**/*.js"
]
};
52 changes: 26 additions & 26 deletions js&css/extension/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,34 @@ document.addEventListener('it-message-from-youtube', function () {
}

switch(message.type) {
case 'channel':
if (!extension.storage.data.blocklist.channels || typeof extension.storage.data.blocklist.channels !== 'object') {
extension.storage.data.blocklist.channels = {};
}
if (message.added) {
extension.storage.data.blocklist.channels[message.id] = {
title: message.title,
preview: message.preview,
when: message.when
}
} else {
delete extension.storage.data.blocklist.channels[message.id];
case 'channel':
if (!extension.storage.data.blocklist.channels || typeof extension.storage.data.blocklist.channels !== 'object') {
extension.storage.data.blocklist.channels = {};
}
if (message.added) {
extension.storage.data.blocklist.channels[message.id] = {
title: message.title,
preview: message.preview,
when: message.when
}
break
} else {
delete extension.storage.data.blocklist.channels[message.id];
}
break

case 'video':
if (!extension.storage.data.blocklist.videos || typeof extension.storage.data.blocklist.videos !== 'object') {
extension.storage.data.blocklist.videos = {};
}
if (message.added) {
extension.storage.data.blocklist.videos[message.id] = {
title: message.title,
when: message.when
}
} else {
delete extension.storage.data.blocklist.videos[message.id];
case 'video':
if (!extension.storage.data.blocklist.videos || typeof extension.storage.data.blocklist.videos !== 'object') {
extension.storage.data.blocklist.videos = {};
}
if (message.added) {
extension.storage.data.blocklist.videos[message.id] = {
title: message.title,
when: message.when
}
break
} else {
delete extension.storage.data.blocklist.videos[message.id];
}
break
}

chrome.storage.local.set({
Expand Down Expand Up @@ -244,5 +244,5 @@ document.addEventListener('it-message-from-youtube', function () {
document.addEventListener('it-play', function (event) {
var videos = document.querySelectorAll('video');
try {chrome.runtime.sendMessage({action: 'play'})}
catch(error){console.log(error); setTimeout(function () { try { chrome.runtime.sendMessage({action: 'play'}, function (response) { console.log(response) } ); } catch { } }, 321) }
catch(error){console.log(error); setTimeout(function () { try { chrome.runtime.sendMessage({action: 'play'}, function (response) { console.log(response) } ); } catch { } }, 321) }
});
Loading

0 comments on commit 39658f7

Please sign in to comment.