Compare commits

..

No commits in common. "preload" and "master" have entirely different histories.

12 changed files with 146 additions and 21 deletions

21
LICENSE.txt Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Shimmermare <shimmermare@gmail.com>
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.

View file

@ -1,8 +0,0 @@
CC ?= gcc
CFLAGS += -fPIC -shared
nyav1.so:
$(CC) $(CFLAGS) nyav1.c -o nyav1.so
.PHONY: clean
clean:
rm -f nyav1.so

9
README.md Normal file
View file

@ -0,0 +1,9 @@
# Not yet, AV1 #
This is extremely lightweight Chrome plugin to disable AV1 on YouTube and other sites.
I believe that AV1 is still very green format and can't be played 4k60fps without hardware support.
Fundamentally this is [h264ify](https://github.com/erkserkserks/h264ify) by [erkserkserks](https://github.com/erkserkserks), but without options and h264-only restriction.
![](example.jpg)

BIN
example.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

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"
}

13
nyav1.c
View file

@ -1,13 +0,0 @@
#include <stdio.h>
#include <dlfcn.h>
static int (*old) (void *a, void *b) = NULL;
int dav1d_open (void *a, void *b) {
int max_frame_delay = *(((int*)b)+1);
if (max_frame_delay == 1) {
if (!old) old = dlsym(RTLD_NEXT, "dav1d_open");
printf("dav1d_open passthrough, max_frame_delay=%d\n", max_frame_delay);
return old(a, b);
}
printf("dav1d_open force -1, max_frame_delay=%d\n", max_frame_delay);
return -1;
}

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 = "(function(){" + 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);
};
}
}