Full Code of erkserkserks/h264ify-firefox for AI

master 1427d222f592 cached
5 files
8.3 KB
2.2k tokens
2 symbols
1 requests
Download .txt
Repository: erkserkserks/h264ify-firefox
Branch: master
Commit: 1427d222f592
Files: 5
Total size: 8.3 KB

Directory structure:
gitextract_lw3wu6xw/

├── README.md
├── data/
│   ├── content_script.js
│   └── inject.js
├── index.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
<meta property="og:image"
    content="https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/icons/icon128.png"/>

# h264ify-firefox

![](https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/noncode/screenshot_video.png)

# About
h264ify is a Firefox/Chrome extension that makes YouTube stream H.264 videos instead of VP8/VP9 videos.

Try h264ify if YouTube videos stutter, take up too much CPU, eat battery life, or make your laptop hot.

By default, YouTube streams VP8/VP9 encoded video. However, this can cause problems with less powerful machines because VP8/VP9 is not typically hardware accelerated.

In contrast, H.264 is commonly hardware accelerated by GPUs, which usually means smoother video playback and reduced CPU usage.

# Requirements
Firefox

Looking for the Chrome version? See: https://github.com/erkserkserks/h264ify

# Installation
Install from here: https://addons.mozilla.org/firefox/addon/h264ify/

If all goes well, when you visit https://www.youtube.com/html5, you should see this:
![](https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/noncode/screenshot_support.png)

Note: The current version of Firefox (35) doesn't support MSE, but when support arrives, h264ify will also block VP9.


================================================
FILE: data/content_script.js
================================================
/**
 * 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 using a script tag.

// 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;
}

// Cache extension preferences in localStorage.
// This is needed because port.on is async and we want to
// load the injection script immediately.
self.port.on('prefs', function(prefs) {
  console.log('port on prefs')
  localStorage['h264ify-enable'] = prefs['enable'];
  localStorage['h264ify-block_60fps'] = prefs['block_60fps'];
});

// Create script elem which will be injected into the page
var script = document.createElement('script');
script.type = 'text/javascript';
// Use textContent instead of src to run inject.js synchronously
script.textContent = self.options.injectjsText;
var html = document.documentElement;
// Inject js into the page
html.insertBefore(script, html.firstChild);
// Clean up
script.remove()


================================================
FILE: data/inject.js
================================================
/**
 * 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 () {
  if (localStorage['h264ify-enable'] === 'false') {
    return;
  }

  // return a custom MIME type checker that can defer to the original function
  function makeModifiedMimeTypeChecker(origFunc) {
    return function (type) {
      if (type === undefined) return '';

      var disallowed_types = ['webm', 'vp8', 'vp9'];
      // If video type is in disallowed_types, say we don't support them
      for (var i = 0; i < disallowed_types.length; i++) {
        if (type.indexOf(disallowed_types[i]) != -1) return '';
      }

      if (localStorage['h264ify-block_60fps'] === 'true') {
        var match = /framerate=(\d+)/.exec(type);
        if (match && match[1] > 30) return '';
      }

      // Otherwise, ask the browser
      return origFunc(type);
    };
  }

  // Override video element canPlayType() function
  var videoElem = document.createElement('video');
  var origCanPlayType = videoElem.canPlayType.bind(videoElem);
  videoElem.__proto__.canPlayType = makeModifiedMimeTypeChecker(origCanPlayType);

  // Override media source extension isTypeSupported() function
  var mse = window.MediaSource;
  // Check for MSE support before use - some versions of FF don't support MSE
  if (mse === undefined) return;
  var origIsTypeSupported = mse.isTypeSupported.bind(mse);
  mse.isTypeSupported = makeModifiedMimeTypeChecker(origIsTypeSupported);
})();



================================================
FILE: index.js
================================================
/**
 * 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.
 */

var data = require('sdk/self').data;
var pageMod = require('sdk/page-mod');

pageMod.PageMod({
  include: '*.youtube.com', 
  contentScriptWhen: 'start',
  contentScriptFile: data.url('content_script.js'),
  contentScriptOptions: {'injectjsText' : data.load('inject.js')},
  onAttach: function(worker) {
    worker.port.emit('prefs', require('sdk/simple-prefs').prefs);

    function onPrefChange(prefName) {
      worker.port.emit('prefs', require('sdk/simple-prefs').prefs);
    }
    require('sdk/simple-prefs').on('', onPrefChange);
  }
});



================================================
FILE: package.json
================================================
{
  "name": "h264ify",
  "description": "Makes YouTube stream H.264 videos instead of VP8/VP9 videos",
  "version": "1.0.5",
  "author": "erkserkserks",
  "engines": {
    "firefox": ">= 38.0a1",
    "fennec": ">= 38.0a1"
  },
  "homepage": "https://github.com/erkserkserks/h264ify-firefox",
  "icon": "icon.png",
  "id": "jid1-TSgSxBhncsPBWQ@jetpack",
  "license": "MIT",
  "permissions": {
    "multiprocess": true,
    "private-browsing": true
  },
  "preferences": [
    {
      "name": "enable",
      "title": "Enable h264ify",
      "type": "bool",
      "value": true
    },
    {
      "name": "block_60fps",
      "title": "Block 60fps",
      "type": "bool",
      "value": false
    }
  ],
  "title": "h264ify"
}
Download .txt
gitextract_lw3wu6xw/

├── README.md
├── data/
│   ├── content_script.js
│   └── inject.js
├── index.js
└── package.json
Download .txt
SYMBOL INDEX (2 symbols across 2 files)

FILE: data/inject.js
  function makeModifiedMimeTypeChecker (line 31) | function makeModifiedMimeTypeChecker(origFunc) {

FILE: index.js
  function onPrefChange (line 36) | function onPrefChange(prefName) {
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9K chars).
[
  {
    "path": "README.md",
    "chars": 1267,
    "preview": "<meta property=\"og:image\"\n    content=\"https://raw.githubusercontent.com/erkserkserks/h264ify-firefox/master/icons/icon1"
  },
  {
    "path": "data/content_script.js",
    "chars": 2324,
    "preview": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, t"
  },
  {
    "path": "data/inject.js",
    "chars": 2527,
    "preview": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, t"
  },
  {
    "path": "index.js",
    "chars": 1693,
    "preview": "/**\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 erkserkserks\n *\n * Permission is hereby granted, free of charge, t"
  },
  {
    "path": "package.json",
    "chars": 725,
    "preview": "{\n  \"name\": \"h264ify\",\n  \"description\": \"Makes YouTube stream H.264 videos instead of VP8/VP9 videos\",\n  \"version\": \"1.0"
  }
]

About this extraction

This page contains the full source code of the erkserkserks/h264ify-firefox GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (8.3 KB), approximately 2.2k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!