Merge upstream

# Conflicts:
#	inject.js
This commit is contained in:
codebicycle
2018-04-14 13:31:08 +03:00
2 changed files with 17 additions and 4 deletions

View File

@@ -24,6 +24,8 @@ Once the extension is installed simply navigate to any page that offers HTML5 vi
* **X** - advance video by 10 seconds. * **X** - advance video by 10 seconds.
* **V** - show/hide the controller. * **V** - show/hide the controller.
Some sites may assign other functionality to same shortcut keys — these collisions are inevitable, unfortunately. As a workaround, we listen both for lower and upper case values (i.e. you can use `Shift-<shortcut>`) if there is other functionality assigned to the lowercase key. This is not a perfect solution, as some sites may listen to both, but works most of the time.
_Note: you can customize these shortcut keys in the extension settings page and even make the extension remember your current playback speed._ _Note: you can customize these shortcut keys in the extension settings page and even make the extension remember your current playback speed._
### FAQ ### FAQ

View File

@@ -226,7 +226,7 @@ chrome.runtime.sendMessage({}, function(response) {
initializeNow(window.document); initializeNow(window.document);
}, false); }, false);
if (document && document.doctype && document.doctype.name == "html") { if (document) {
if (document.readyState === "complete") { if (document.readyState === "complete") {
initializeNow(document); initializeNow(document);
} else { } else {
@@ -241,7 +241,7 @@ chrome.runtime.sendMessage({}, function(response) {
function initializeNow(document) { function initializeNow(document) {
// enforce init-once due to redundant callers // enforce init-once due to redundant callers
if (document.body.classList.contains('vsc-initialized')) { if (!document.body || document.body.classList.contains('vsc-initialized')) {
return; return;
} }
document.body.classList.add('vsc-initialized'); document.body.classList.add('vsc-initialized');
@@ -380,7 +380,7 @@ chrome.runtime.sendMessage({}, function(response) {
} else if (action === 'slower') { } else if (action === 'slower') {
// Video min rate is 0.0625: // Video min rate is 0.0625:
// https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp?l=167 // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp?l=167
var s = Math.max(v.playbackRate - tc.settings.speedStep, 0.0625); var s = Math.max(v.playbackRate - tc.settings.speedStep, 0.07);
v.playbackRate = Number(s.toFixed(2)); v.playbackRate = Number(s.toFixed(2));
} else if (action === 'reset') { } else if (action === 'reset') {
resetSpeed(v, 1.0); resetSpeed(v, 1.0);
@@ -398,7 +398,18 @@ chrome.runtime.sendMessage({}, function(response) {
function resetSpeed(v, target) { function resetSpeed(v, target) {
if (v.playbackRate === target) { if (v.playbackRate === target) {
if(v.playbackRate === tc.settings.resetSpeed)
{
if (target !== 1.0) {
v.playbackRate = 1.0;
} else {
v.playbackRate = tc.settings.fastSpeed;
}
}
else
{
v.playbackRate = tc.settings.resetSpeed; v.playbackRate = tc.settings.resetSpeed;
}
} else { } else {
tc.settings.resetSpeed = v.playbackRate; tc.settings.resetSpeed = v.playbackRate;
chrome.storage.local.set({'resetSpeed': v.playbackRate}); chrome.storage.local.set({'resetSpeed': v.playbackRate});