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

Commit

Permalink
Parse cc option from youtube watch page and pass to min vid (#530)
Browse files Browse the repository at this point in the history
- fixes #522
  • Loading branch information
meandavejustice committed Dec 23, 2016
1 parent bacdbb3 commit a28880d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion data/icon-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ function ytWatchElementHandler(el) {
tmp.addEventListener('click', function(ev) {
evNoop(ev);
const videoEl = document.querySelector('video');
const cc = !!(document.querySelector('.ytp-subtitles-button').getAttribute('aria-pressed') !== 'false');
videoEl.pause();
closeFullscreen();
self.port.emit('launch', {
url: window.location.href,
domain: 'youtube.com',
time: videoEl.currentTime,
volume: videoEl.volume,
muted: videoEl.muted
muted: videoEl.muted,
cc: cc
});
});
el.appendChild(tmp);
Expand Down
5 changes: 4 additions & 1 deletion lib/get-youtube-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ const qs = require('sdk/querystring');

module.exports = getYouTubeUrl;

function getYouTubeUrl(videoId, cb, time) {
function getYouTubeUrl(videoId, cb, time, cc) {
if (!cc) cc = false;

const params = qs.stringify({
autoplay: time ? 1 : 0,
modestbranding: 1,
controls: 0,
disablekb: 0,
enablejsapi: 1,
fs: 0,
cc_load_policy: +cc, // force boolean to number
iv_load_policy: 3,
loop: 0,
rel: 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/launch-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ function launchVideo(opts) {
url: id ? '' : opts.url,
player: player
});
}, opts.time);
}, opts.time, opts.cc);
});
}

0 comments on commit a28880d

Please sign in to comment.