Skip to content

Commit

Permalink
[v1.5.0] - Changed the playbackRate caching/storing logic
Browse files Browse the repository at this point in the history
- Uses some more global constants.
- Minor release since it does heavily affect the way the extension functions.
- So far, if the object existed with say an OttName of netflix, but the user was on APV, it would replace that object with a different one. The current structure is much more elegant and easier to maintain, and most importantly WORKS AS EXPECTED!
  • Loading branch information
BRAiNCHiLD95 committed Nov 18, 2019
1 parent 08a5608 commit c13823b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
36 changes: 21 additions & 15 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const playerDivs = {
"div.controls-overlay div.bottom-panel div.controls-container div.bottom-right-panel",
};

var currentlyOn = null;

const uvpc = { netflix: 1, primevideo: 1, hotstar: 1 };

/**
* Updates the BadgeText for the Extension
* @param {Port} port
Expand All @@ -36,20 +40,21 @@ const deployer = async (msg, port) => {
if (!videoElement) return false;
var injectedController = await injectController(msg.domain);
if (!injectedController.success) return false;

chrome.storage.sync.get(["uvpc"], data => {
if (data.uvpc && data.uvpc.ottName === msg.domain) {
videoElement.playbackRate = data.uvpc.playbackRate;
document.getElementById("rangeVal").innerHTML = data.uvpc.playbackRate+'x';
document.getElementById("uvpc-value").value = data.uvpc.playbackRate;
} else {
chrome.storage.sync.set({
uvpc: { ottName: msg.domain, playbackRate: videoElement.playbackRate },
});
}
updateBadgeText(port, videoElement);
videoElement.onloadeddata = attachListeners(port, videoElement);
});
currentlyOn = msg.domain;
if (currentlyOn && videoElement && injectedController.success) {
chrome.storage.sync.get(["uvpc"], data => {
if (data.uvpc) {
videoElement.playbackRate = data.uvpc[currentlyOn];
document.getElementById("rangeVal").innerHTML =
data.uvpc[currentlyOn] + "x";
document.getElementById("uvpc-value").value = data.uvpc[currentlyOn];
} else {
chrome.storage.sync.set({ uvpc });
}
updateBadgeText(port, videoElement);
videoElement.onloadeddata = attachListeners(port, videoElement);
});
}
};

/**
Expand All @@ -60,6 +65,7 @@ const connectToServices = () => {
const initContent = chrome.runtime.connect({ name: "uvpc-b" });
initContent.postMessage({ initiated: true });
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
var currentlyOn = msg.domain;
deployer(msg, initContent);
});
};
Expand Down Expand Up @@ -155,7 +161,7 @@ const valueChanged = (port, event, videoElement) => {
videoElement.playbackRate = event.target.valueAsNumber;
chrome.storage.sync.get(["uvpc"], data => {
let uvpc = data.uvpc;
uvpc.playbackRate = videoElement.playbackRate;
uvpc[currentlyOn] = videoElement.playbackRate;
chrome.storage.sync.set({ uvpc });
updateBadgeText(port, videoElement);
});
Expand Down
Binary file modified images/popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Ultimate Video Playback Controller",
"short_name": "UVPC",
"description": "An Ultimate Controller manipulating Video Playback Speeds across OTT platforms",
"version": "1.4.1",
"version": "1.5.0",
"manifest_version": 2,
"icons": {
"128": "images/icon_128.png"
Expand Down
2 changes: 1 addition & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<h6 class="text-info">Ultimate Video Playback Controller</h6>
</div>
<div class="col-12 text-center">
<span id="version" class="text-muted">(v1.4.1)</span>
<span id="version" class="text-muted">(v1.5.0)</span>
</div>
</div>
<div id="ottDiv" class="row">
Expand Down

0 comments on commit c13823b

Please # to comment.