Revert built-in youtube codec check plugin

This commit is contained in:
EAZYBLACK 2026-09-25 15:17:16 +03:00
commit dc7f319dde
6 changed files with 0 additions and 176 deletions

View file

@ -32,17 +32,6 @@
name="media.peerconnection.enabled" name="media.peerconnection.enabled"
type="bool"/> type="bool"/>
#endif #endif
<!-- YouTube video codecs -->
<preference id="browser.video.youtube.hide-unaccelerated"
name="browser.video.youtube.hide-unaccelerated"
type="bool"/>
<preference id="browser.video.youtube.force-h264"
name="browser.video.youtube.force-h264"
type="bool"/>
<preference id="browser.video.youtube.disable-60fps"
name="browser.video.youtube.disable-60fps"
type="bool"/>
</preferences> </preferences>
<script type="application/javascript" <script type="application/javascript"
@ -79,28 +68,8 @@
</rows> </rows>
</grid> </grid>
</groupbox> </groupbox>
#endif #endif
<!-- YouTube video codecs -->
<groupbox id="videoGroup" data-category="paneContent" hidden="true">
<caption><label>&videoContent.label;</label></caption>
<vbox>
<checkbox id="youtubeHideUnaccelerated"
preference="browser.video.youtube.hide-unaccelerated"
label="&youtubeHideUnaccelerated.label;"
accesskey="&youtubeHideUnaccelerated.accesskey;" />
<checkbox id="youtubeForceH264"
preference="browser.video.youtube.force-h264"
label="&youtubeForceH264.label;"
accesskey="&youtubeForceH264.accesskey;" />
<checkbox id="youtubeDisable60fps"
preference="browser.video.youtube.disable-60fps"
label="&youtubeDisable60fps.label;"
accesskey="&youtubeDisable60fps.accesskey;" />
</vbox>
</groupbox>
<groupbox id="notificationsGroup" data-category="paneContent" hidden="true"> <groupbox id="notificationsGroup" data-category="paneContent" hidden="true">
<caption><label>&notificationsPolicy.label;</label></caption> <caption><label>&notificationsPolicy.label;</label></caption>
<grid> <grid>

View file

@ -1,77 +0,0 @@
/*
* Adapted from enhanced-h264ify's inject_codec_check.js.
*
* The MIT License (MIT)
* Copyright (c) 2019 alextrv
* Copyright (c) 2015 erkserkserks
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*/
/* YouTube-only codec selection controls. */
(function () {
"use strict";
var settings = window.__dactyloidaeYouTubeVideoSettings || {};
var originalCanPlayType = HTMLMediaElement.prototype.canPlayType;
var originalIsTypeSupported = window.MediaSource &&
window.MediaSource.isTypeSupported;
function isVideoType(type) {
return /(^|\s|;)video\//i.test(type) ||
/(^|[; ])codecs\s*=\s*["']?(?:avc|vp0|av0)/i.test(type);
}
function isBlocked(type) {
if (!type || !isVideoType(type)) {
return false;
}
// AV1 is always blocked, independently of the preferences.
if (/av01|av99/i.test(type)) {
return true;
}
if (settings.forceH264 && !/avc1|avc3/i.test(type)) {
return true;
}
if (settings.hideUnaccelerated &&
!settings.vp9HardwareAccelerated && /vp9|vp09/i.test(type)) {
return true;
}
if (settings.disable60fps) {
var match = /(?:framerate|fps)\s*=\s*([0-9]+(?:\.[0-9]+)?)/i.exec(type);
if (match && Number(match[1]) > 30) {
return true;
}
}
return false;
}
HTMLMediaElement.prototype.canPlayType = function (type) {
if (isBlocked(type)) {
return "";
}
return originalCanPlayType.call(this, type);
};
if (window.MediaSource && originalIsTypeSupported) {
window.MediaSource.isTypeSupported = function (type) {
if (isBlocked(type)) {
return false;
}
return originalIsTypeSupported.call(this, type);
};
}
}());

View file

@ -99,62 +99,6 @@ InternalUserscriptsService.prototype = {
} }
} catch (e) {} } catch (e) {}
let contentWin = win.wrappedJSObject || win; let contentWin = win.wrappedJSObject || win;
let documentURI = null;
try {
documentURI = win.document.documentURIObject;
} catch (e) {}
// The codec shim is deliberately limited to YouTube. Use the browser's
// decoder probe rather than guessing from the user's graphics settings.
let documentHost = null;
try {
// nsIURI.host is not implemented by hostless URI schemes (about:, data:,
// moz-extension:, and others), so reading it can throw.
if (documentURI) {
documentHost = documentURI.host;
}
} catch (e) {}
if (documentHost &&
/(^|\.)youtube(?:-nocookie)?\.com$/i.test(documentHost)) {
let settings = {
hideUnaccelerated: Services.prefs.getBoolPref(
"browser.video.youtube.hide-unaccelerated", true),
forceH264: Services.prefs.getBoolPref(
"browser.video.youtube.force-h264", false),
disable60fps: Services.prefs.getBoolPref(
"browser.video.youtube.disable-60fps", false),
vp9HardwareAccelerated: false,
};
let loadCodecShim = function (vp9HardwareAccelerated) {
settings.vp9HardwareAccelerated = vp9HardwareAccelerated;
contentWin.__dactyloidaeYouTubeVideoSettings = settings;
try {
Services.scriptloader.loadSubScript(
"chrome://internaluserscripts/content/bundled-scripts/youtube-codec-check.user.js",
contentWin);
} catch (e) {}
};
try {
let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let hardwareSupport = utils.supportsHardwareVP9Decoding;
if (hardwareSupport && typeof hardwareSupport.then === "function") {
hardwareSupport.then(function (result) {
loadCodecShim(/^Yes;/.test(result));
}, function () {
loadCodecShim(false);
});
} else {
loadCodecShim(/^Yes;/.test(hardwareSupport));
}
} catch (e) {
loadCodecShim(false);
}
}
let logPolyfill = function (name, source) { let logPolyfill = function (name, source) {
try { try {
if ( if (

View file

@ -3,6 +3,3 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
pref("browser.internal-userscripts.enabled", true); pref("browser.internal-userscripts.enabled", true);
pref("browser.video.youtube.hide-unaccelerated", true);
pref("browser.video.youtube.force-h264", false);
pref("browser.video.youtube.disable-60fps", false);

View file

@ -30,5 +30,4 @@ FINAL_TARGET_FILES['internal-userscripts'] += [
'bundled-scripts/textencoderstream-polyfill.user.js', 'bundled-scripts/textencoderstream-polyfill.user.js',
'bundled-scripts/transformstream-polyfill.user.js', 'bundled-scripts/transformstream-polyfill.user.js',
'bundled-scripts/webauthn-microsoft-shim.user.js', 'bundled-scripts/webauthn-microsoft-shim.user.js',
'bundled-scripts/youtube-codec-check.user.js',
] ]

View file

@ -52,11 +52,3 @@
<!ENTITY javascriptWebrtc.label "Enable WebRTC"> <!ENTITY javascriptWebrtc.label "Enable WebRTC">
<!ENTITY javascriptWebrtc.accesskey "R"> <!ENTITY javascriptWebrtc.accesskey "R">
#endif #endif
<!ENTITY videoContent.label "Video">
<!ENTITY youtubeHideUnaccelerated.label "Hide codecs from YouTube that aren't hardware accelerated">
<!ENTITY youtubeHideUnaccelerated.accesskey "H">
<!ENTITY youtubeForceH264.label "Force H264 on YouTube">
<!ENTITY youtubeForceH264.accesskey "F">
<!ENTITY youtubeDisable60fps.label "Disable 60fps video on YouTube">
<!ENTITY youtubeDisable60fps.accesskey "D">