mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 15:57:31 +09:00
Add YouTube codec check and their settings
This commit is contained in:
parent
f56f753c74
commit
9230d4f436
6 changed files with 157 additions and 0 deletions
|
|
@ -99,6 +99,54 @@ InternalUserscriptsService.prototype = {
|
|||
}
|
||||
} catch (e) {}
|
||||
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.
|
||||
if (documentURI &&
|
||||
documentURI.host &&
|
||||
/(^|\.)youtube(?:-nocookie)?\.com$/i.test(documentURI.host)) {
|
||||
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) {
|
||||
try {
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue