Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"hideSuggestedAction": { "message": "Hide Suggested Action 'View products'" },
"hideMerchShelf": { "message": "Hide 'Merch Shelf'" },
{
"hideSuggestedAction": {
"message": "Hide Suggested Action 'View products'"
},
"hideMerchShelf": {
"message": "Hide 'Merch Shelf'"
},
"about": {
"message": "About"
},
Expand Down Expand Up @@ -133,6 +137,9 @@
"autoPictureInPicture": {
"message": "Auto Picture-In-Picture"
},
"autoBypassContentWarning": {
"message": "Bypass content warnings"
},
"autoplay": {
"message": "Autoplay"
},
Expand Down Expand Up @@ -1618,4 +1625,4 @@
"youtubesLight": {
"message": "YouTube's Light"
}
}
}
44 changes: 44 additions & 0 deletions js&css/extension/bypass-content-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Fixes GitHub issue #3591: Auto-bypass "I understand and wish to proceed" content warnings
(function () {
let enabled = true; // Default to true

// Load setting
chrome.storage.sync.get('auto_bypass_content_warning', (data) => {
if (data.auto_bypass_content_warning !== undefined) {
enabled = data.auto_bypass_content_warning;
}
if (enabled) bypassContentWarning();
});

// Listen for changes
chrome.storage.onChanged.addListener((changes, area) => {
if (area === 'sync' && changes.auto_bypass_content_warning) {
enabled = changes.auto_bypass_content_warning.newValue;
if (enabled) bypassContentWarning();
}
});

// Only run on YouTube watch pages
const isWatchPage = () => location.pathname === '/watch';

// Add &rco=1 to URL if missing
function bypassContentWarning() {
if (!enabled) return;

if (isWatchPage() && !location.search.includes('rco=1')) {
const url = new URL(location.href);
url.searchParams.set('rco', '1');
history.replaceState(history.state, '', url.toString());
}
}

// Handle YouTube (SPA) navigation
window.addEventListener('yt-navigate-finish', bypassContentWarning);

// Fallback: Observe DOM changes to detect URL updates
new MutationObserver(() => {
if (enabled && isWatchPage() && !location.search.includes('rco=1')) {
bypassContentWarning();
}
}).observe(document, { subtree: true, childList: true });
})();
30 changes: 22 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"id": "{3c6bf0cc-3ae2-42fb-9993-0d33104fdcaf}"
}
},
"background": {
"background": {
"service_worker": "background.js"
},
"action": {
Expand Down Expand Up @@ -51,16 +51,28 @@
"js&css/extension/www.youtube.com/general/general.js",
"js&css/extension/www.youtube.com/appearance/sidebar/sidebar.js",
"js&css/extension/www.youtube.com/appearance/comments/comments.js",
"js&css/extension/bypass-content-warning.js",
"js&css/extension/init.js"
],
"matches": ["https://www.youtube.com/*"],
"matches": [
"https://www.youtube.com/*"
],
"run_at": "document_start"
}
],
"host_permissions": ["https://www.youtube.com/*"],
"optional_host_permissions": ["https://returnyoutubedislikeapi.com/*"],
"optional_permissions": ["downloads"],
"permissions": ["contextMenus", "storage"],
"host_permissions": [
"https://www.youtube.com/*"
],
"optional_host_permissions": [
"https://returnyoutubedislikeapi.com/*"
],
"optional_permissions": [
"downloads"
],
"permissions": [
"contextMenus",
"storage"
],
"web_accessible_resources": [
{
"resources": [
Expand All @@ -83,7 +95,9 @@
"js&css/web-accessible/init.js",
"menu/icons/48.png"
],
"matches": ["https://www.youtube.com/*"]
"matches": [
"https://www.youtube.com/*"
]
}
]
}
}
Loading