Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Mar 17, 2022
1 parent 8677a2a commit d194ace
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/assets/javascripts/helpers/youtube/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export async function initOptions() {
invidiousVrMode = r.invidiousVrMode ?? true;
invidiousSavePlayerPos = r.invidiousSavePlayerPos ?? false;

pipedBufferGoal = r.pipedBufferGoal ?? 10;
pipedBufferGoal = r.pipedBufferGoal ?? 300;
pipedComments = r.pipedComments ?? true;
pipedDisableLBRY = r.pipedDisableLBRY ?? false;
pipedEnabledCodecs = r.pipedEnabledCodecs ?? ["av1", "vp9", "avc"];
Expand Down
4 changes: 2 additions & 2 deletions src/assets/javascripts/helpers/youtube/piped-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ browser.storage.local.get(
let youtubeVolume = r.youtubeVolume ?? 100;
let youtubeListen = r.youtubeListen ?? false;

let pipedBufferGoal = r.pipedBufferGoal ?? 10;
let pipedBufferGoal = r.pipedBufferGoal ?? 300;
let pipedComments = r.pipedComments ?? true;
let pipedDisableLBRY = r.pipedDisableLBRY ?? false;
let pipedEnabledCodecs = r.pipedEnabledCodecs ?? ["av1", "vp9", "avc"];
Expand All @@ -39,7 +39,7 @@ browser.storage.local.get(
let pipedSponsorblock = r.pipedSponsorblock ?? true;
let pipedWatchHistory = r.pipedWatchHistory ?? false;

localStorage.setItem("bufferGoal", pipedBufferGoal);
localStorage.setItem("bufferGoal", pipedBufferGoal.toString());
localStorage.setItem("comments", pipedComments);
localStorage.setItem("disableLBRY", pipedDisableLBRY);
localStorage.setItem("enabledCodecs", pipedEnabledCodecs);
Expand Down
51 changes: 25 additions & 26 deletions src/assets/javascripts/helpers/youtube/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function isPipedorInvidious(url, type, frontend) {
}

function initPipedLocalStorage(tabId) {
if (enableCustomSettings)
if (!disable && frontend == 'piped' && enableCustomSettings)
browser.tabs.executeScript(
tabId,
{
Expand All @@ -552,7 +552,7 @@ function initPipedLocalStorage(tabId) {
}

function initPipedMaterialLocalStorage(tabId) {
if (enableCustomSettings)
if (!disable && frontend == 'pipedMaterial' && enableCustomSettings)
browser.tabs.executeScript(
tabId,
{
Expand All @@ -563,15 +563,13 @@ function initPipedMaterialLocalStorage(tabId) {
}

function initInvidiousCookies() {

let checkedInstances = [
...invidiousNormalRedirectsChecks,
...invidiousNormalCustomRedirects,
...invidiousTorRedirectsChecks,
...invidiousTorCustomRedirects,
];

if (enableCustomSettings)
if (!disable && frontend == 'invidious' && enableCustomSettings) {
let checkedInstances = [
...invidiousNormalRedirectsChecks,
...invidiousNormalCustomRedirects,
...invidiousTorRedirectsChecks,
...invidiousTorCustomRedirects,
];
for (const instanceUrl of checkedInstances)
browser.cookies.get(
{
Expand All @@ -580,17 +578,17 @@ function initInvidiousCookies() {
},
cookie => {
let prefs = {};
if (cookie) {
prefs = JSON.parse(decodeURIComponent(cookie.value));
browser.cookies.remove({ url: instanceUrl, name: "PREFS" });
}
// if (cookie) {
// prefs = JSON.parse(decodeURIComponent(cookie.value));
// browser.cookies.remove({ url: instanceUrl, name: "PREFS" });
// }

prefs.local = invidiousAlwaysProxy == 'true';
prefs.local = invidiousAlwaysProxy;
prefs.dark_mode = theme;
prefs.video_loop = invidiousVideoLoop == 'true';
prefs.continue_autoplay = invidiousContinueAutoplay == 'true';
prefs.continue = invidiousContinue == 'true';
prefs.listen = youtubeListen == 'true';
prefs.video_loop = invidiousVideoLoop;
prefs.continue_autoplay = invidiousContinueAutoplay;
prefs.continue = invidiousContinue;
prefs.listen = youtubeListen;
prefs.speed = parseFloat(invidiousSpeed);
prefs.quality = invidiousQuality;
prefs.quality_dash = invidiousQualityDash;
Expand All @@ -605,15 +603,15 @@ function initInvidiousCookies() {
prefs.captions[1] = invidiousCaptions[1];
prefs.captions[2] = invidiousCaptions[2];

prefs.related_videos = invidiousRelatedVideos == 'true';
prefs.annotations = invidiousAnnotations == 'true'
prefs.extend_desc = invidiousExtendDesc == 'true';
prefs.vr_mode = invidiousVrMode == 'true';
prefs.save_player_pos = invidiousSavePlayerPos == 'true';
prefs.related_videos = invidiousRelatedVideos;
prefs.annotations = invidiousAnnotations
prefs.extend_desc = invidiousExtendDesc;
prefs.vr_mode = invidiousVrMode;
prefs.save_player_pos = invidiousSavePlayerPos;

prefs.volume = parseInt(volume);
prefs.player_style = invidiousPlayerStyle;
prefs.youtubeAutoplay = youtubeAutoplay == 'true';
prefs.autoplay = youtubeAutoplay;

browser.cookies.set({
url: instanceUrl,
Expand All @@ -622,6 +620,7 @@ function initInvidiousCookies() {
})
}
)
}
}

let theme;
Expand Down
26 changes: 16 additions & 10 deletions src/pages/options/youtube/invidious.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,31 @@ invidiousSavePlayerPosElement.addEventListener("change",
);

youtubeHelper.init().then(() => {
invidiousVideoLoopElement.checked = youtubeHelper.getInvidiousVideoLoop();

invidiousPlayerStyleElement.value = youtubeHelper.getInvidiousPlayerStyle();
invidiousAlwaysProxyElement.value = youtubeHelper.getInvidiousAlwaysProxy();
invidiousVideoLoopElement.value = youtubeHelper.getInvidiousVideoLoop();
invidiousContinueAutoplayElement.value = youtubeHelper.getInvidiousContinueAutoplay();
invidiousContinueElement.value = youtubeHelper.getInvidiousContinue();
youtubeListenElement.value = youtubeHelper.getYoutubeListen();

invidiousContinueAutoplayElement.checked = youtubeHelper.getInvidiousContinueAutoplay();
invidiousContinueElement.checked = youtubeHelper.getInvidiousContinue();
invidiousAlwaysProxyElement.checked = youtubeHelper.getInvidiousAlwaysProxy();
youtubeListenElement.checked = youtubeHelper.getYoutubeListen();

invidiousSpeedElement.value = youtubeHelper.getInvidiousSpeed();
invidiousQualityElement.value = youtubeHelper.getInvidiousQuality();
invidiousQualityDashElement.value = youtubeHelper.getInvidiousQualityDash();

invidiousComments0Element.value = youtubeHelper.getInvidiousComments()[0];
invidiousComments1Element.value = youtubeHelper.getInvidiousComments()[1];

invidiousCaptions0Element.value = youtubeHelper.getInvidiousCaptions()[0];
invidiousCaptions1Element.value = youtubeHelper.getInvidiousCaptions()[1];
invidiousCaptions2Element.value = youtubeHelper.getInvidiousCaptions()[2];
invidiousRelatedVideoElement.value = youtubeHelper.getInvidiousRelatedVideos();
invidiousAnnotationsElement.value = youtubeHelper.getInvidiousAnnotations();
invidiousExtendDescElement.value = youtubeHelper.getInvidiousExtendDesc();
invidiousVrModeElement.value = youtubeHelper.getInvidiousVrMode();
invidiousSavePlayerPosElement.value = youtubeHelper.getInvidiousSavePlayerPos();

invidiousRelatedVideoElement.checked = youtubeHelper.getInvidiousRelatedVideos();
invidiousAnnotationsElement.checked = youtubeHelper.getInvidiousAnnotations();
invidiousExtendDescElement.checked = youtubeHelper.getInvidiousExtendDesc();
invidiousVrModeElement.checked = youtubeHelper.getInvidiousVrMode();
invidiousSavePlayerPosElement.checked = youtubeHelper.getInvidiousSavePlayerPos();

commonHelper.processDefaultCustomInstances(
'invidious',
Expand Down
14 changes: 8 additions & 6 deletions src/pages/options/youtube/piped.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function selectSkipModify(value, boolean) {
youtubeHelper.setPipedSelectedSkip(selectSkip)
}

let pipedSelectedSkipSponsorElement = document.getElementById("piped-selectedSkip-sponsors");
let pipedSelectedSkipSponsorElement = document.getElementById("piped-selectedSkip-sponsor");
pipedSelectedSkipSponsorElement.addEventListener("change",
event => selectSkipModify('sponsors', event.target.checked)
event => selectSkipModify('sponsor', event.target.checked)
);

let pipedSelectedSkipIntroElement = document.getElementById("piped-selectedSkip-intro");
Expand Down Expand Up @@ -148,9 +148,9 @@ pipedMaterialSkipToLastPointElement.addEventListener("change",
);


let pipedMaterialSelectedSkipSponsorElement = document.getElementById("pipedMaterial-selectedSkip-sponsors");
let pipedMaterialSelectedSkipSponsorElement = document.getElementById("pipedMaterial-selectedSkip-sponsor");
pipedMaterialSelectedSkipSponsorElement.addEventListener("change",
event => selectSkipModify('sponsors', event.target.checked)
event => selectSkipModify('sponsor', event.target.checked)
);

let pipedMaterialSelectedSkipIntroElement = document.getElementById("pipedMaterial-selectedSkip-intro");
Expand Down Expand Up @@ -198,7 +198,9 @@ youtubeHelper.init().then(() => {

pipedSponsorblockElement.checked = youtubeHelper.getPipedSponsorblock();
selectSkip = youtubeHelper.getPipedSelectedSkip();
pipedSelectedSkipSponsorElement.checked = selectSkip.includes('sponsors');
console.log("selectSkip", selectSkip)
pipedSelectedSkipSponsorElement.checked = selectSkip.includes('sponsor');
console.log("selectSkip.includes('sponsor')", selectSkip.includes('sponsor'))
pipedSelectedSkipIntroElement.checked = selectSkip.includes('intro');
pipedSelectedSkipOutroElement.checked = selectSkip.includes('outro');
pipedSelectedSkipPreviewElement.checked = selectSkip.includes('preview');
Expand All @@ -224,7 +226,7 @@ youtubeHelper.init().then(() => {
pipedMaterialProxyLBRYElement.checked = youtubeHelper.getPipedProxyLBRY();
pipedMaterialSponsorblockElement.checked = youtubeHelper.getPipedSponsorblock()
pipedMaterialSkipToLastPointElement.checked = youtubeHelper.getPipedMaterialSkipToLastPoint();
pipedMaterialSelectedSkipSponsorElement.checked = selectSkip.includes('sponsors');
pipedMaterialSelectedSkipSponsorElement.checked = selectSkip.includes('sponsor');
pipedMaterialSelectedSkipIntroElement.checked = selectSkip.includes('intro');
pipedMaterialSelectedSkipOutroElement.checked = selectSkip.includes('outro');
pipedMaterialSelectedSkipPreviewElement.checked = selectSkip.includes('preview');
Expand Down
14 changes: 7 additions & 7 deletions src/pages/options/youtube/youtube.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ <h4>Always loop</h4>
</div>

<div class="some-block option-block">
<h4>Autoplay next video</h4>
<input id="invidious-continue_autoplay" type="checkbox" />
<h4>Play next by default</h4>
<input id="invidious-continue" type="checkbox" />
</div>

<div class="some-block option-block">
<h4>Play next by default</h4>
<input id="invidious-continue" type="checkbox" />
<h4>Autoplay next video</h4>
<input id="invidious-continue_autoplay" type="checkbox" />
</div>

<div class="some-block option-block">
Expand Down Expand Up @@ -779,7 +779,7 @@ <h4>Enable Sponsorblock</h4>

<div class="some-block option-block">
<h4>Skip Sponsors</h4>
<input id="piped-selectedSkip-sponsors" type="checkbox" />
<input id="piped-selectedSkip-sponsor" type="checkbox" />
</div>

<div class="some-block option-block">
Expand Down Expand Up @@ -845,7 +845,7 @@ <h4>Default Quality</h4>

<div class="some-block option-block">
<h4>Buffering Goal (in seconds)</h4>
<input id="piped-bufferGoal" type="number" min="0" />
<input id="piped-bufferGoal" type="number" min="10" />
</div>

<div class="some-block option-block">
Expand Down Expand Up @@ -1174,7 +1174,7 @@ <h4>Skip to the last watched point when encountering a video already seen</h4>

<div class="some-block option-block">
<h4>Skip Sponsors</h4>
<input id="pipedMaterial-selectedSkip-sponsors" type="checkbox" />
<input id="pipedMaterial-selectedSkip-sponsor" type="checkbox" />
</div>

<div class="some-block option-block">
Expand Down
3 changes: 0 additions & 3 deletions src/pages/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ wholeInit().then(() => {
disableLbryElement.checked = !lbryHelper.getDisable();

let changeInstanceElement = document.getElementById("change-instance")
changeInstanceElement.disabled = !changeInstance();
changeInstanceElement.addEventListener("click", changeInstance);
})

Expand Down Expand Up @@ -198,8 +197,6 @@ function changeInstance() {
return false;
}



let popupFrontends;
generalHelper.init().then(() => {
popupFrontends = generalHelper.getPopupFrontends();
Expand Down

0 comments on commit d194ace

Please sign in to comment.