diff --git a/README.md b/README.md
index 869ea78..e9e8263 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ This plugins helps to keep this important resource free and available to everyon
## Make a Donation
**This adblocker is 100% free to use and always will be.
-It has helped over 100,000 people remove the unbearable ads from Youtube.**
+It has helped over 120,000 people remove the unbearable ads from Youtube.**
This project has been made entirely by myself, as just one developer. Countless hours and late nights have gone into making this and I continue to work on updating and maintaining the project regularly. I remain dedicated to ensuring this solution continues to work for everyone (despite Youtube's best efforts to stop adblockers).
diff --git a/goodtube.js b/goodtube.js
index 9ea579b..267dd7b 100644
--- a/goodtube.js
+++ b/goodtube.js
@@ -27,6 +27,25 @@
getParams[decode(arguments[1])] = decode(arguments[2]);
});
+ // For some users, the URL will contain the video ID as part of the URL
+ // Example - "/watch/xxxx" or "/live/xxxx"
+ // In this case, we want to add it manually as "v" (just like for /watch?v=xxxx)
+ if (goodTube_helper_watchingVideo() && typeof getParams['v'] === 'undefined') {
+ let splitString = '';
+ if (window.location.href.indexOf('/watch/') !== -1) {
+ splitString = '/watch/';
+ }
+ else {
+ splitString = '/live/';
+ }
+
+ let bits = window.location.href.split(splitString);
+ if (bits.length === 2) {
+ let endBits = bits[1].split('?');
+ getParams['v'] = endBits[endBits.length - 1];
+ }
+ }
+
return getParams;
}
@@ -123,6 +142,18 @@
}
}
+ // Check if we're watching a video
+ function goodTube_helper_watchingVideo() {
+ // If the URL contains "/watch/" or "/watch?" or "/live/", we're viewing a video
+ if (window.location.href.indexOf('/watch/') !== -1 || window.location.href.indexOf('/watch?') !== -1 || window.location.href.indexOf('/live/') !== -1) {
+ return true;
+ }
+ // Otherwise, we're not viewing a video
+ else {
+ return false;
+ }
+ }
+
/* Global variables
------------------------------------------------------------------------------------------ */
@@ -495,7 +526,7 @@
if (
(goodTube_shorts === 'true' && window.location.href.indexOf('/shorts') !== -1)
||
- window.location.href.indexOf('/watch?') === -1
+ !goodTube_helper_watchingVideo()
) {
// Clear timeout first to solve memory leak issues
clearTimeout(goodTube_youtube_pauseMuteVideos_timeout);
@@ -591,7 +622,7 @@
let goodTube_youtube_checkAdsState_timeout = setTimeout(() => {}, 0);
function goodTube_youtube_checkAdsState() {
// If we're viewing a video
- if (window.location.href.indexOf('/watch?') !== -1) {
+ if (goodTube_helper_watchingVideo()) {
// Get the ads DOM elements
let adsElement = document.querySelector('.video-ads');
let sponsoredAdsElement = document.querySelector('.ad-simple-attributed-string');
@@ -721,7 +752,7 @@
let goodTube_clearedPlayer = false;
function goodTube_player_positionAndSize() {
// If we're viewing a video
- if (window.location.href.indexOf('/watch?') !== -1) {
+ if (goodTube_helper_watchingVideo()) {
// If the "hide and mute ads" fallback is inactive
if (goodTube_fallback) {
if (!goodTube_clearedPlayer) {
@@ -836,7 +867,7 @@
// If we're loading for the first time
if (goodTube_firstLoad) {
// If we're not viewing a video
- if (window.location.href.indexOf('/watch?') === -1) {
+ if (!goodTube_helper_watchingVideo()) {
// Clear and hide the player
goodTube_player_clear();
}
@@ -879,13 +910,16 @@
let goodTube_player_setQualitySucceeded = false;
let goodTube_player_setQuality_timeout = setTimeout(() => {}, 0);
function goodTube_player_setAutoQuality(quality = 'highest') {
+ // DISABLE FOR NOW THIS IS CAUSING ISSUES
+ return;
+
// Only do this once
if (goodTube_player_setQualitySucceeded) {
return;
}
// Make sure we're watching a video
- if (window.location.href.indexOf('/watch?') === -1) {
+ if (!goodTube_helper_watchingVideo()) {
return;
}
@@ -1165,7 +1199,7 @@
let keyPressed = event.key.toLowerCase();
// Don't do anything IF we're holding control OR alt OR the command key (mac) OR we're not watching a video
- if (event.ctrlKey || event.altKey || event.metaKey || window.location.href.indexOf('/watch?') === -1) {
+ if (event.ctrlKey || event.altKey || event.metaKey || !goodTube_helper_watchingVideo()) {
return;
}
@@ -1573,7 +1607,7 @@
}
// Sync main player (only if we're viewing a video page AND the "hide and mute ads" fallback is inactive)
- else if (event.data.indexOf('goodTube_syncMainPlayer_') !== -1 && window.location.href.indexOf('/watch?') !== -1 && !goodTube_fallback) {
+ else if (event.data.indexOf('goodTube_syncMainPlayer_') !== -1 && goodTube_helper_watchingVideo() && !goodTube_fallback) {
// Parse the data
let syncTime = parseFloat(event.data.replace('goodTube_syncMainPlayer_', ''));
@@ -1584,7 +1618,7 @@
goodTube_page_api = document.getElementById('movie_player');
// Make sure the API is all good
- if (!goodTube_page_api || typeof goodTube_page_api.seekTo !== 'function' || typeof goodTube_page_api.playVideo !== 'function') {
+ if (!goodTube_page_api || typeof goodTube_page_api.seekTo !== 'function' || typeof goodTube_page_api.playVideo !== 'function' || typeof goodTube_page_api.mute !== 'function' || typeof goodTube_page_api.setVolume !== 'function') {
return;
}
@@ -1601,6 +1635,10 @@
// Sync the current time using the page API - 500ms (this is the only reliable way)
goodTube_page_api.seekTo((syncTime - .5));
+ // Then mute the video via the page API (this helps to prevent audio flashes)
+ goodTube_page_api.mute();
+ goodTube_page_api.setVolume(0);
+
// Then mute the video via HTML (playing it unmutes it for some reason)
youtubeVideoElement.volume = 0;
youtubeVideoElement.muted = true;
@@ -1684,7 +1722,7 @@
goodTube_getParams = goodTube_helper_setupGetParams();
// If we're viewing a video
- if (window.location.href.indexOf('/watch?') !== -1) {
+ if (goodTube_helper_watchingVideo()) {
// Load the video
goodTube_player_load();
@@ -1702,7 +1740,7 @@
}
// If we're viewing a video
- if (window.location.href.indexOf('/watch?') !== -1) {
+ if (goodTube_helper_watchingVideo()) {
// Show or hide the end screen (based on autoplay, not the setting)
goodTube_nav_showHideEndScreen();
@@ -1825,7 +1863,7 @@