diff --git a/README.md b/README.md index 0794795..003e21c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ - + # h264ify - - ![](https://raw.githubusercontent.com/erkserkserks/h264ify/master/noncode/yt_screenshot.png) # About @@ -16,16 +13,13 @@ By default, YouTube streams VP8/VP9 encoded video. However, this can cause probl In contrast, H.264 is commonly hardware accelerated by GPUs, which usually means smoother video playback and reduced CPU usage. # Requirements -Google Chrome - -Looking for the Firefox version? See: https://github.com/erkserkserks/h264ify-firefox +Google Chrome *or* Mozilla Firefox # Installation -Install from here: https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal - -Note: [You may need to enable GPU acceleration as well] (http://www.webupd8.org/2014/01/enable-hardware-acceleration-in-chrome.html) +- [Chrome Web Store](https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal) -If all goes well, when you visit https://www.youtube.com/html5, you should see this: -![](https://github.com/erkserkserks/h264ify/blob/master/noncode/html5_video_support.png) +- [Firefox Add-on](https://addons.mozilla.org/en-US/firefox/addon/h264ify/) +To check that it's working, right click on a YouTube video and select "Stats for nerds". Verify that the codec being used is neither 'vp08' nor 'vp09'. +Note: [You may need to enable GPU acceleration as well](http://www.webupd8.org/2014/01/enable-hardware-acceleration-in-chrome.html) diff --git a/manifest.json b/manifest.json index 5c9c751..5001a80 100644 --- a/manifest.json +++ b/manifest.json @@ -26,8 +26,8 @@ "*://*.youtu.be/*" ], "js": [ - "src/inject/inject.js", - "src/inject/content_script.js" + "src/inject.js", + "src/content_script.js" ], "run_at": "document_start", "all_frames": true diff --git a/options.html b/options.html index d9ae0f1..7550bd8 100644 --- a/options.html +++ b/options.html @@ -19,6 +19,6 @@

  • - + diff --git a/src/inject/content_script.js b/src/content_script.js similarity index 50% rename from src/inject/content_script.js rename to src/content_script.js index 6ed6aed..d1d55ee 100644 --- a/src/inject/content_script.js +++ b/src/content_script.js @@ -26,39 +26,13 @@ // javascript variables on the youtube page. Thus, we have to inject another // script into the DOM. -// Set defaults for options stored in localStorage -if (localStorage['h264ify-enable'] === undefined) { - localStorage['h264ify-enable'] = true; -} -if (localStorage['h264ify-block_60fps'] === undefined) { - localStorage['h264ify-block_60fps'] = false; -} -if (localStorage['h264ify-battery_only'] === undefined) { - localStorage['h264ify-battery_only'] = false; -} +chrome.storage.local.get({ enable: true, block_60fps: false, battery_only: false }, options => { + const optionsJson = JSON.stringify(options) -// Cache chrome.storage.local options in localStorage. -// This is needed because chrome.storage.local.get() is async and we want to -// load the injection script immediately. -// See https://bugs.chromium.org/p/chromium/issues/detail?id=54257 -chrome.storage.local.get({ - // Set defaults - enable: true, - block_60fps: false, - battery_only: false, - }, function(options) { - localStorage['h264ify-enable'] = options.enable; - localStorage['h264ify-block_60fps'] = options.block_60fps; - localStorage['h264ify-battery_only'] = options.battery_only; - } -); - -var injectScript = document.createElement('script'); -// Use textContent instead of src to run inject() synchronously -injectScript.textContent = inject.toString() + "inject();"; -injectScript.onload = function() { - // Remove