Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Jul 8, 2024
1 parent afa1766 commit 074c7fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
11 changes: 6 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ chrome.runtime.onInstalled.addListener(function (installed) {
});
} else if (installed.reason == 'install') {
if (navigator.userAgent.indexOf("Firefox") != -1) {
chrome.storage.local.set({below_player_pip: false})}
chrome.storage.local.set({below_player_pip: false})
}

Check failure on line 99 in background.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Expected indentation of 2 tabs but found 3
if (navigator.userAgent.indexOf('Safari') !== -1
&& (!/Windows|Chrom/.test(navigator.userAgent)
|| /Macintosh|iPhone/.test(navigator.userAgent))) {
chrome.storage.local.set({below_player_pip: false})
// still needed? (are screenshots broken in Safari?):
chrome.storage.local.set({below_player_screenshot: false})}
chrome.storage.local.set({below_player_screenshot: false})
}

Check failure on line 106 in background.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Expected indentation of 2 tabs but found 3
// console.log('Thanks for installing!');
}
});
Expand Down Expand Up @@ -312,9 +314,8 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
} catch (error) {
console.error(error);
}
} else {
console.error('Permission is not granted.');
}})
} else { console.error('Permission is not granted.'); }
})

Check failure on line 318 in background.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Expected indentation of 3 tabs but found 4
break
}
});
Expand Down
10 changes: 5 additions & 5 deletions js&css/extension/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ 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) }
});
document.addEventListener('it-play', function () {
// var videos = document.querySelectorAll('video');
try {chrome.runtime.sendMessage({action: 'play'})

Check failure on line 246 in js&css/extension/init.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Statement inside of curly braces should be on next line
} catch (error) {console.log(error); setTimeout(function () { try { chrome.runtime.sendMessage({action: 'play'}, function (response) { console.log(response) } ); } catch { } }, 321) }
});
14 changes: 7 additions & 7 deletions js&css/web-accessible/www.youtube.com/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,20 @@ ImprovedTube.shortcutScreenshot = ImprovedTube.screenshot;
------------------------------------------------------------------------------*/
ImprovedTube.shortcutIncreasePlaybackSpeed = function () { const value = Number(this.storage.shortcuts_playback_speed_step) || .05,
// original:
var video = this.elements.video;
const video = this.elements.video;
if (video) {if ( video.playbackRate){
if ( video.playbackRate < 1 && video.playbackRate > 1-ImprovedTube.storage.shortcut_playback_speed_step ) {
video.playbackRate = 1 } // aligning at 1.0 instead of passing by 1.0
else { video.playbackRate = Math.min(Math.max(Number((video.playbackRate + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),24);
}
else { video.playbackRate = Math.min(Math.max(Number((video.playbackRate + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),16);
} // Firefox doesnt limit speed to 16x. We can allow more in Firefox if people ask
ImprovedTube.showStatus(video.playbackRate);
} else {
// alternative:
var player = this.elements.player;
const player = this.elements.player;
if (player) {
if ( player.getPlaybackRate() < 1 && player.getPlaybackRate() > 1-ImprovedTube.storage.shortcut_playback_speed_step ) {
player.setPlaybackRate(1) } // aligning at 1.0 instead of passing by 1.0
else { player.setPlaybackRate(Math.min(Math.max(Number((player.getPlaybackRate() + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),24))
else { player.setPlaybackRate(Math.min(Math.max(Number((player.getPlaybackRate() + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),16))
}
ImprovedTube.showStatus(player.getPlaybackRate());
}}}};
Expand All @@ -377,7 +377,7 @@ ImprovedTube.shortcutIncreasePlaybackSpeed = function () { const value = Number(
------------------------------------------------------------------------------*/
ImprovedTube.shortcutDecreasePlaybackSpeed = function () { const value = Number(ImprovedTube.storage.shortcut_playback_speed_step) || .05;
// original:
var video = this.elements.video;
const video = this.elements.video;
if (video) {
if (video.playbackRate){
if ( video.playbackRate < 0.1+ImprovedTube.storage.shortcut_playback_speed_step ) {
Expand All @@ -388,7 +388,7 @@ ImprovedTube.shortcutDecreasePlaybackSpeed = function () { const value = Number(
}
else {
// alternative:
var player = this.elements.player;
const player = this.elements.player;
if (player) {
if ( player.getPlaybackRate() < 0.1+ImprovedTube.storage.shortcut_playback_speed_step ) {
player.setPlaybackRate(player.getPlaybackRate()*0.7) } // slow down near minimum
Expand Down

0 comments on commit 074c7fa

Please sign in to comment.