[
  {
    "path": "README.md",
    "content": "<meta property=\"og:image\"\n    content=\"https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/icons/icon128.png\"/>\n\n# h264ify-firefox\n\n![](https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/noncode/screenshot_video.png)\n\n# About\nh264ify is a Firefox/Chrome extension that makes YouTube stream H.264 videos instead of VP8/VP9 videos.\n\nTry h264ify if YouTube videos stutter, take up too much CPU, eat battery life, or make your laptop hot.\n\nBy default, YouTube streams VP8/VP9 encoded video. However, this can cause problems with less powerful machines because VP8/VP9 is not typically hardware accelerated.\n\nIn contrast, H.264 is commonly hardware accelerated by GPUs, which usually means smoother video playback and reduced CPU usage.\n\n# Requirements\nFirefox\n\nLooking for the Chrome version? See: https://github.com/erkserkserks/h264ify\n\n# Installation\nInstall from here: https://addons.mozilla.org/firefox/addon/h264ify/\n\nIf all goes well, when you visit https://www.youtube.com/html5, you should see this:\n![](https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/noncode/screenshot_support.png)\n\nNote: The current version of Firefox (35) doesn't support MSE, but when support arrives, h264ify will also block VP9.\n"
  },
  {
    "path": "data/content_script.js",
    "content": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// This content script runs in an isolated environment and cannot modify any\n// javascript variables on the youtube page. Thus, we have to inject another\n// script into the DOM using a script tag.\n\n// Set defaults for options stored in localStorage\nif (localStorage['h264ify-enable'] === undefined) {\n  localStorage['h264ify-enable'] = true;\n}\nif (localStorage['h264ify-block_60fps'] === undefined) {\n  localStorage['h264ify-block_60fps'] = false;\n}\n\n// Cache extension preferences in localStorage.\n// This is needed because port.on is async and we want to\n// load the injection script immediately.\nself.port.on('prefs', function(prefs) {\n  console.log('port on prefs')\n  localStorage['h264ify-enable'] = prefs['enable'];\n  localStorage['h264ify-block_60fps'] = prefs['block_60fps'];\n});\n\n// Create script elem which will be injected into the page\nvar script = document.createElement('script');\nscript.type = 'text/javascript';\n// Use textContent instead of src to run inject.js synchronously\nscript.textContent = self.options.injectjsText;\nvar html = document.documentElement;\n// Inject js into the page\nhtml.insertBefore(script, html.firstChild);\n// Clean up\nscript.remove()\n"
  },
  {
    "path": "data/inject.js",
    "content": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n(function () {\n  if (localStorage['h264ify-enable'] === 'false') {\n    return;\n  }\n\n  // return a custom MIME type checker that can defer to the original function\n  function makeModifiedMimeTypeChecker(origFunc) {\n    return function (type) {\n      if (type === undefined) return '';\n\n      var disallowed_types = ['webm', 'vp8', 'vp9'];\n      // If video type is in disallowed_types, say we don't support them\n      for (var i = 0; i < disallowed_types.length; i++) {\n        if (type.indexOf(disallowed_types[i]) != -1) return '';\n      }\n\n      if (localStorage['h264ify-block_60fps'] === 'true') {\n        var match = /framerate=(\\d+)/.exec(type);\n        if (match && match[1] > 30) return '';\n      }\n\n      // Otherwise, ask the browser\n      return origFunc(type);\n    };\n  }\n\n  // Override video element canPlayType() function\n  var videoElem = document.createElement('video');\n  var origCanPlayType = videoElem.canPlayType.bind(videoElem);\n  videoElem.__proto__.canPlayType = makeModifiedMimeTypeChecker(origCanPlayType);\n\n  // Override media source extension isTypeSupported() function\n  var mse = window.MediaSource;\n  // Check for MSE support before use - some versions of FF don't support MSE\n  if (mse === undefined) return;\n  var origIsTypeSupported = mse.isTypeSupported.bind(mse);\n  mse.isTypeSupported = makeModifiedMimeTypeChecker(origIsTypeSupported);\n})();\n\n"
  },
  {
    "path": "index.js",
    "content": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nvar data = require('sdk/self').data;\nvar pageMod = require('sdk/page-mod');\n\npageMod.PageMod({\n  include: '*.youtube.com', \n  contentScriptWhen: 'start',\n  contentScriptFile: data.url('content_script.js'),\n  contentScriptOptions: {'injectjsText' : data.load('inject.js')},\n  onAttach: function(worker) {\n    worker.port.emit('prefs', require('sdk/simple-prefs').prefs);\n\n    function onPrefChange(prefName) {\n      worker.port.emit('prefs', require('sdk/simple-prefs').prefs);\n    }\n    require('sdk/simple-prefs').on('', onPrefChange);\n  }\n});\n\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"h264ify\",\n  \"description\": \"Makes YouTube stream H.264 videos instead of VP8/VP9 videos\",\n  \"version\": \"1.0.5\",\n  \"author\": \"erkserkserks\",\n  \"engines\": {\n    \"firefox\": \">= 38.0a1\",\n    \"fennec\": \">= 38.0a1\"\n  },\n  \"homepage\": \"https://github.com/erkserkserks/h264ify-firefox\",\n  \"icon\": \"icon.png\",\n  \"id\": \"jid1-TSgSxBhncsPBWQ@jetpack\",\n  \"license\": \"MIT\",\n  \"permissions\": {\n    \"multiprocess\": true,\n    \"private-browsing\": true\n  },\n  \"preferences\": [\n    {\n      \"name\": \"enable\",\n      \"title\": \"Enable h264ify\",\n      \"type\": \"bool\",\n      \"value\": true\n    },\n    {\n      \"name\": \"block_60fps\",\n      \"title\": \"Block 60fps\",\n      \"type\": \"bool\",\n      \"value\": false\n    }\n  ],\n  \"title\": \"h264ify\"\n}\n"
  }
]