Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Milestone: v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vovcacik committed Nov 28, 2013
1 parent 4c620f6 commit 0a52824
Show file tree
Hide file tree
Showing 11 changed files with 1,541 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
high-definition-video
High Definition Video
=====================

Firefox addon that makes HD the default video quality.
Supported video players:
- YouTube
- _more added on request_
9 changes: 9 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
setlocal

for /F "usebackq tokens=3 delims=<>" %%v in (`type install.rdf ^| findstr /irc:"em:version"`) do (
set version=%%v
)

7za a -tzip high_definition_video-%version%-fx.xpi -i@build.include -x@build.exclude
exit /B 0
Empty file added build.exclude
Empty file.
4 changes: 4 additions & 0 deletions build.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chrome\
chrome.manifest
install.rdf
icon.png
2 changes: 2 additions & 0 deletions chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
content hdv chrome/content/ contentaccessible=yes
overlay chrome://browser/content/browser.xul chrome://hdv/content/browserOverlay.xul
19 changes: 19 additions & 0 deletions chrome/content/browserOverlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var hdv = {
init: function() {
if (gBrowser) gBrowser.addEventListener("DOMContentLoaded", this.onDOMContentLoaded);
},
onDOMContentLoaded: function(event) {
var doc = event.originalTarget;
if (!doc || !doc.body) return;

var script = doc.createElement('script');
script.setAttribute("type", "application/javascript");
script.setAttribute("src", "chrome://hdv/content/hdv.js");
doc.body.appendChild(script);
}
}

window.addEventListener("load", function() {
hdv.init();
window.removeEventListener("load", this, false);
});
6 changes: 6 additions & 0 deletions chrome/content/browserOverlay.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<overlay id="hdv_browserOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://hdv/content/browserOverlay.js"/>
</overlay>
22 changes: 22 additions & 0 deletions chrome/content/hdv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @see https://developers.google.com/youtube/js_api_reference
*/
function onYouTubePlayerReady(player){
// The onYouTubePlayerReady() is called twice. During first call the 'player'
// parameter equals to player ID string. On the second call it equals to
// the player object. Make sure we respond to the second call only.
if (player && typeof player === "object") {
// We need to be little bit stubborn about playback quality setting, because:
// a) getAvailableQualityLevels() sometimes returns empty array
// b) YouTube website is forcing default quality between 0 - 3000 ms of
// playback (I didn't observe this with embedded video though)
var intervalId = window.setInterval(function() {
var highestQuality = player.getAvailableQualityLevels()[0] || "highres";
if (player.getPlaybackQuality() === highestQuality) {
window.clearInterval(intervalId);
} else {
player.setPlaybackQuality(highestQuality);
}
}, 100);
}
}
1,450 changes: 1,450 additions & 0 deletions icon.ai

Large diffs are not rendered by default.

Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions install.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">

<Description about="urn:mozilla:install-manifest">
<em:id>hdv@vovcacik.addons.mozilla.org</em:id>
<em:type>2</em:type>

<em:name>High Definition Video</em:name>
<em:version>1.0</em:version>
<em:description>Makes HD the default video quality.</em:description>
<em:creator>Vlastimil Ovčáčík</em:creator>
<em:homepageURL>https://addons.mozilla.org/addon/high-definition-video/</em:homepageURL>

<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>9.0</em:minVersion>
<em:maxVersion>28.0a1</em:maxVersion>
</Description>
</em:targetApplication>

</Description>
</RDF>

0 comments on commit 0a52824

Please sign in to comment.