Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Added a temporary work around for the subscriptions feed being comple…
Browse files Browse the repository at this point in the history
…tely empty when navigating back
  • Loading branch information
probablyraging committed Jun 9, 2023
1 parent 4b08cc7 commit f179210
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/constants/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ chrome.runtime.onInstalled.addListener(async (details) => {
// chrome.tabs.reload(tab.id);
// });
// });
chrome.storage.sync.set({ presentModal: true }).catch(() => { console.log('[STORAGE] Could not set storage item') });
chrome.action.setBadgeBackgroundColor({ color: '#ed5a64' });
chrome.action.setBadgeText({ text: '1' });
chrome.storage.sync.set({ presentModal: false }).catch(() => { console.log('[STORAGE] Could not set storage item') });
// chrome.action.setBadgeBackgroundColor({ color: '#ed5a64' });
// chrome.action.setBadgeText({ text: '1' });
}
});

Expand Down
31 changes: 31 additions & 0 deletions src/constants/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
// Some temporary work around to prevent the subscriptions page from being completely empty at times
let wasVisitedFirst = false;
let movedAway = false;
function checkContents() {
if (location.href === 'https://www.youtube.com/feed/subscriptions') {
if (document.readyState === 'complete') {
wasVisitedFirst = true;
setTimeout(() => {
const contents = document.querySelector('#contents');
const computedStyles = getComputedStyle(contents);
if (computedStyles.width === '90%') {
if (wasVisitedFirst && movedAway) {
location.reload();
} else {
setTimeout(checkContents, 1000);
}
} else {
setTimeout(checkContents, 1000);
}
}, 1000);
} else {
setTimeout(checkContents, 1000);
}
} else {
if (wasVisitedFirst && location.href !== 'https://www.youtube.com/') movedAway = true;
setTimeout(checkContents, 1000);
}
}

checkContents();

function checkStates() {
// If the extension is unloaded or updated, reload the page to terminate orphaned scripts
if (!chrome.runtime.id) return location.reload();
Expand Down

0 comments on commit f179210

Please sign in to comment.