Implement

This commit is contained in:
Shimmermare 2019-11-02 16:40:38 +03:00
parent 900d75e408
commit f74bc3529e
7 changed files with 116 additions and 0 deletions

BIN
icons/128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
icons/16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

BIN
icons/48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
icons/original.psd Normal file

Binary file not shown.

27
manifest.json Normal file
View file

@ -0,0 +1,27 @@
{
"manifest_version": 2,
"name": "Not yet, AV1",
"version": "1.0.0",
"description": "Extremely lightweight Chrome plugin to disable AV1 on YouTube and other sites.",
"icons": {
"16": "icons/16.png",
"48": "icons/48.png",
"128": "icons/128.png"
},
"content_scripts": [
{
"matches": [
"*://*.youtube.com/*",
"*://*.youtube-nocookie.com/*",
"*://*.youtu.be/*"
],
"js": [
"src/inject/inject.js",
"src/inject/content_script.js"
],
"run_at": "document_start",
"all_frames": true
}
],
"homepage_url": "https://github.com/Shimmermare/NotYetAV1"
}

View file

@ -0,0 +1,37 @@
/**
* The MIT License (MIT)
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// This content script runs in an isolated environment and cannot modify any
// javascript variables on the youtube page. Thus, we have to inject another
// script into the DOM.
var injectScript = document.createElement('script');
// Use textContent instead of src to run inject() synchronously
injectScript.textContent = inject.toString() + "inject();";
injectScript.onload = function() {
// Remove <script> node after injectScript runs.
this.parentNode.removeChild(this);
};
(document.head || document.documentElement).appendChild(injectScript);

52
src/inject/inject.js Normal file
View file

@ -0,0 +1,52 @@
/**
* The MIT License (MIT)
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
function inject() {
override();
function override() {
// Override video element canPlayType() function
var videoElem = document.createElement('video');
var origCanPlayType = videoElem.canPlayType.bind(videoElem);
videoElem.__proto__.canPlayType = makeModifiedTypeChecker(origCanPlayType);
// Override media source extension isTypeSupported() function
var mse = window.MediaSource;
// Check for MSE support before use
if (mse === undefined) return;
var origIsTypeSupported = mse.isTypeSupported.bind(mse);
mse.isTypeSupported = makeModifiedTypeChecker(origIsTypeSupported);
}
// return a custom MIME type checker that can defer to the original function
function makeModifiedTypeChecker(origChecker) {
// Check if a video type is allowed
return function (type) {
if (type === undefined || type.indexOf('av01') !== -1) return '';
// Otherwise, ask the browser
return origChecker(type);
};
}
}