Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some spelling mistakes #298

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ You may also test the extension with Firefox by running `npm run dev:firefox`, w
### Versioning

The `manifest.json` contains two version numbers: `version` and `version_name`.
Packages that are released/uploaded to webstores will have both of these version numbers set to the same value.
Packages that are released/uploaded to web stores will have both of these version numbers set to the same value.
During development, smaller changes may get pushed to the `main` branch.
These packages will have the same `version` number as the latest release, but a newer `version_name` number, often including a `-beta` suffix, to distinguish them from the latest release.

Expand Down
4 changes: 2 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Background service worker for the extension, which is run ("started") on extension initialization
// Handles communication between the extension and the content script as well as Firebase interactions
import { configSync, setSyncStorageValue } from "./chromeStorage.js";
// We need to import utils.js to get the console rerouting function
// We need to import utils.js to get the console re-routing function
import { } from "./utils.js";

// ---------- Initialization/Chrome event listeners ----------
Expand Down Expand Up @@ -163,7 +163,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
case "overwritePlaylistInfoInDB":
updatePlaylistInfoInDB('uploadsPlaylists/' + request.data.key, request.data.val, true).then(sendResponse);
break;
// Before v1.0.0 the videos were stored in an array without upload times, so they need to all be refetched
// Before v1.0.0 the videos were stored in an array without upload times, so they need to all be re-fetched
case 'updateDBPlaylistToV1.0.0':
updateDBPlaylistToV1_0_0('uploadsPlaylists/' + request.data.key).then(sendResponse);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const shufflingHints = [
"The 'Shuffle' button will display a progress percentage if the extension has to fetch data from the YouTube API!",

// Errors
"Whenever an error is encountered, an alert will open with more detailed information on what caused it, and how you may resolve it. If you still need assistence, please open an issue on GitHub and include the channel ID!",
"Whenever an error is encountered, an alert will open with more detailed information on what caused it, and how you may resolve it. If you still need assistance, please open an issue on GitHub and include the channel ID!",

// General options
"Use the 'Open in new tab' option to open each shuffled video in its own tab!",
Expand Down
4 changes: 2 additions & 2 deletions src/html/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (isPopup) {
const isFirefox = typeof browser !== "undefined";
const domElements = getPopupDomElements();
await setPopupDomElementValuesFromConfig(domElements);
await setPopupDomElemenEventListeners(domElements);
await setPopupDomElementEventListeners(domElements);
await determineOverlayVisibility(domElements);

// Restart the background script if it was stopped to make sure the shuffle button immediately works
Expand Down Expand Up @@ -199,7 +199,7 @@ async function setPopupDomElementValuesFromConfig(domElements) {
}

// Set event listeners for DOM elements
async function setPopupDomElemenEventListeners(domElements) {
async function setPopupDomElementEventListeners(domElements) {
// Shuffling: Open in new tab option toggle
domElements.shuffleOpenInNewTabOptionToggle.addEventListener("change", async function () {
await setSyncStorageValue("shuffleOpenInNewTabOption", this.checked);
Expand Down
4 changes: 2 additions & 2 deletions src/html/shufflingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ try {
const port = chrome.runtime.connect({ name: "shufflingPage" });

const domElements = getDomElements();
await setDomElemenEventListeners(domElements);
await setDomElementEventListeners(domElements);

// If this page is open, it means the user has clicked the shuffle button
shuffleButtonClicked();
Expand Down Expand Up @@ -59,7 +59,7 @@ function getDomElements() {
}

// Set event listeners for DOM elements
async function setDomElemenEventListeners(domElements) {
async function setDomElementEventListeners(domElements) {
// View changelog button
domElements.viewChangelogButton.addEventListener("click", async function () {
await setSyncStorageValue("lastViewedChangelogVersion", chrome.runtime.getManifest().version);
Expand Down
4 changes: 2 additions & 2 deletions src/html/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const currentVersion = chrome.runtime.getManifest().version_name ?? chrome.runti
domElements.updateHeading.innerText = `Random YouTube Video - v${currentVersion}`;

await buildShufflingHints(domElements);
await setPopupDomElemenEventListeners(domElements);
await setPopupDomElementEventListeners(domElements);

// ---------- DOM ----------
// Get all relevant DOM elements
Expand Down Expand Up @@ -64,7 +64,7 @@ function getDomElements() {
}

// Set event listeners for DOM elements
async function setPopupDomElemenEventListeners(domElements) {
async function setPopupDomElementEventListeners(domElements) {
// Firefox permissions button
if (isFirefox && !await browser.permissions.contains({ permissions: ["tabs"], origins: ["*://*.youtube.com/*"] })) {
domElements.firefoxPermissionsDiv.classList.remove("hidden");
Expand Down
16 changes: 8 additions & 8 deletions src/shuffleVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async function handlePlaylistDatabaseUpload(playlistInfo, uploadsPlaylistId, sho
playlistInfo["lastUpdatedDBAt"] = new Date().toISOString();

let videosToDatabase = {};
// If any videos need to be deleted, this should be the union of videos, newvideos, minus the videos to delete
// If any videos need to be deleted, this should be the union of videos, new videos, minus the videos to delete
if (encounteredDeletedVideos) {
console.log("Some videos need to be deleted from the database. All current videos will be uploaded to the database...");
videosToDatabase = getAllVideosFromLocalPlaylist(playlistInfo);
Expand Down Expand Up @@ -798,7 +798,7 @@ async function chooseRandomVideosFromPlaylist(playlistInfo, channelId, shouldUpd
randomVideo = videosToShuffle[Math.floor(Math.random() * videosToShuffle.length)];
numVideosProcessed++;

console.log(`The chosen video does not exist anymore, so it will be removed from the database. A new random video has been chosen: ${randomVideo}`);
console.log(`The chosen video does not exist any more, so it will be removed from the database. A new random video has been chosen: ${randomVideo}`);

if (randomVideo === undefined) {
// If we haven't chosen any videos yet, the channel does not contain any videos
Expand Down Expand Up @@ -832,7 +832,7 @@ async function chooseRandomVideosFromPlaylist(playlistInfo, channelId, shouldUpd
// What follows is dependent on if the video is a short or not, and the user's settings
// Case 1: !isShort && ignoreShorts => Success
if (!videoIsShort && configSync.shuffleIgnoreShortsOption == "2") {
// Move the video to the knownVideos subdictionary
// Move the video to the knownVideos sub-dictionary
playlistInfo["videos"]["knownVideos"][randomVideo] = playlistInfo["videos"]["unknownType"][randomVideo];
delete playlistInfo["videos"]["unknownType"][randomVideo];

Expand All @@ -844,7 +844,7 @@ async function chooseRandomVideosFromPlaylist(playlistInfo, channelId, shouldUpd
} else if (videoIsShort && configSync.shuffleIgnoreShortsOption == "2") {
console.log('A chosen video was a short, but shorts are ignored. Choosing a new random video.');

// Move the video to the knownShorts subdictionary
// Move the video to the knownShorts sub-dictionary
playlistInfo["videos"]["knownShorts"][randomVideo] = playlistInfo["videos"]["unknownType"][randomVideo];
delete playlistInfo["videos"]["unknownType"][randomVideo];

Expand All @@ -857,7 +857,7 @@ async function chooseRandomVideosFromPlaylist(playlistInfo, channelId, shouldUpd

// Case 3: isShort && onlyShorts => Success
} else if (videoIsShort && configSync.shuffleIgnoreShortsOption == "0") {
// Move the video to the knownShorts subdictionary
// Move the video to the knownShorts sub-dictionary
playlistInfo["videos"]["knownShorts"][randomVideo] = playlistInfo["videos"]["unknownType"][randomVideo];
delete playlistInfo["videos"]["unknownType"][randomVideo];

Expand All @@ -869,7 +869,7 @@ async function chooseRandomVideosFromPlaylist(playlistInfo, channelId, shouldUpd
} else if (!videoIsShort && configSync.shuffleIgnoreShortsOption == "0") {
console.log('A chosen video was not a short, but only shorts should be shuffled. Choosing a new random video.');

// Move the video to the knownVideos subdictionary
// Move the video to the knownVideos sub-dictionary
playlistInfo["videos"]["knownVideos"][randomVideo] = playlistInfo["videos"]["unknownType"][randomVideo];
delete playlistInfo["videos"]["unknownType"][randomVideo];

Expand Down Expand Up @@ -1047,7 +1047,7 @@ async function playVideo(chosenVideos, firedFromPopup) {

// Open the video in a new tab, the reusable tab or the current tab
// If the shuffle button from the popup was used, we always open the video in the 'same tab' (==the shuffling page)
// If the user wants to reuse tabs, we only open in a new tab if the reusable tab is not open anymore
// If the user wants to reuse tabs, we only open in a new tab if the reusable tab is not open any more
if (configSync.shuffleOpenInNewTabOption && !firedFromPopup) {
const pageType = getPageTypeFromURL(window.location.href);
// Video page: Pause the current video if it is playing
Expand All @@ -1062,7 +1062,7 @@ async function playVideo(chosenVideos, firedFromPopup) {
if (featuredPlayer && featuredPlayer.classList.contains('playing-mode') && !featuredPlayer.classList.contains('unstarted-mode')) {
featuredPlayer.children[0].click();
}
// Any page: Pause the miniplayer if it exists and is playing
// Any page: Pause the mini-player if it exists and is playing
const miniPlayer = document.querySelector('ytd-player#ytd-player')?.children[0]?.children[0];
if (miniPlayer && miniPlayer.classList.contains('playing-mode') && !miniPlayer.classList.contains('unstarted-mode')) {
miniPlayer.children[0].click();
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Global utilities

/* c8 ignore start - The console reroutings cannot be tested correctly */
// ---------- Console rerouting ----------
/* c8 ignore start - The console re-routings cannot be tested correctly */
// ---------- Console re-routing ----------
const oldLog = console.log;
console.log = function () {
// The last argument to console.log is a boolean that determines if the message should be shown in production
Expand Down
2 changes: 1 addition & 1 deletion static/html/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Changelog - Random YouTube Video</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link id="RandomYoutubeVideoStyleSheet" rel="stylesheet" href="../css/popup.css" />
<link rel="stylesheet" href="../css/popup.css" />
</head>

<body id="randomYoutubeVideoBody">
Expand Down
6 changes: 3 additions & 3 deletions static/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<title>Options - Random YouTube Video</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link id="RandomYoutubeVideoStyleSheet" rel="stylesheet" href="../css/popup.css" />
<link id="RandomYoutubeVideoStyleSheet" rel="stylesheet" href="../css/toggle.css" />
<link rel="stylesheet" href="../css/popup.css" />
<link rel="stylesheet" href="../css/toggle.css" />
</head>

<body id="randomYoutubeVideoBody" class="randomYoutubeVideoPopupBody">
Expand Down Expand Up @@ -87,7 +87,7 @@ <h3>Shuffle Settings</h3>

<!-- Shuffling: Open in new tab option toggle -->
<div class="toggle optionsRow-item">
<label id="shuffleReUseNewTabOption" title="If this is enabled, the first new tab opened by the extension when shuffling will be reused, as long as it is still on a youtube subpage.">
<label id="shuffleReUseNewTabOption" title="If this is enabled, the first new tab opened by the extension when shuffling will be reused, as long as it is still on a youtube sub-page.">
Reuse new tab
<input type="checkbox" id="shuffleReUseNewTabOptionToggle" />
<span class="slider"></span>
Expand Down
2 changes: 1 addition & 1 deletion static/html/shufflingPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Shuffling... - Random YouTube Video</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link id="RandomYoutubeVideoStyleSheet" rel="stylesheet" href="../css/popup.css" />
<link rel="stylesheet" href="../css/popup.css" />
</head>

<body id="randomYoutubeVideoBody">
Expand Down
2 changes: 1 addition & 1 deletion static/html/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Welcome - Random YouTube Video</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link id="RandomYoutubeVideoStyleSheet" rel="stylesheet" href="../css/popup.css" />
<link rel="stylesheet" href="../css/popup.css" />
</head>

<body id="randomYoutubeVideoBody">
Expand Down
12 changes: 6 additions & 6 deletions test/shuffleVideo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ describe('shuffleVideo', function () {
beforeEach(function () {
// ---------- Fetch mock responses ----------
// ----- YT API responses -----
// Combine the local, db and newVideos into one object, but remove locally deleted videos, as they do not exist in the YT API anymore
// Combine the local, db and newVideos into one object, but remove locally deleted videos, as they do not exist in the YT API any more
let allVideos = deepCopy({ ...input.dbVideos, ...input.localVideos, ...input.newUploadedVideos });
for (const [videoId, publishTime] of Object.entries(allVideos)) {
if (videoId.startsWith('DEL_LOC')) {
Expand Down Expand Up @@ -918,7 +918,7 @@ describe('shuffleVideo', function () {
beforeEach(function () {
// ---------- Fetch mock responses ----------
// ----- YT API responses -----
// Combine the local, db and newVideos into one object, but remove locally deleted videos, as they do not exist in the YT API anymore
// Combine the local, db and newVideos into one object, but remove locally deleted videos, as they do not exist in the YT API any more
let allVideos = deepCopy({ ...input.dbVideos, ...input.localVideos, ...input.newUploadedVideos });
for (const [videoId, publishTime] of Object.entries(allVideos)) {
if (videoId.startsWith('DEL_LOC')) {
Expand Down Expand Up @@ -1072,10 +1072,10 @@ describe('shuffleVideo', function () {
const numDeletedVideosBefore = Object.keys(input.dbDeletedVideos).filter(videoId => videoId.includes('DEL')).length;
const numDeletedVideosAfter = Object.keys(getAllVideosAsOneObject(playlistInfoAfter)).filter(videoId => videoId.includes('DEL')).length;

// Callcount:
// Call count:
// 6 if we need to fetch from the YT API, with update or overwrite depending on if a video was deleted
// 5 if we don't need to fetch from the YT API, but need to overwrite the playlist in the DB
// 4 if we dont need to overwrite the playlist in the DB
// 4 if we don't need to overwrite the playlist in the DB
switch (chrome.runtime.sendMessage.callCount) {
case 4:
expect(numDeletedVideosBefore).to.be(numDeletedVideosAfter);
Expand Down Expand Up @@ -1116,9 +1116,9 @@ describe('shuffleVideo', function () {
expect(commands).to.contain('getAllYouTubeTabs');
expect(commands).to.contain('getCurrentTabId');

// Callcount:
// Call count:
// 6 if we need to fetch from the YT API, we consequently need to update the DB
// 4 if we dont need to fetch from the YT API
// 4 if we don't need to fetch from the YT API
if (needsYTAPIInteraction(input)) {
expect(chrome.runtime.sendMessage.callCount).to.be(6);
expect(commands).to.contain('getAPIKey');
Expand Down
2 changes: 1 addition & 1 deletion test/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ afterEach(async function () {
});

// ----- Helpers -----
// Reimplementation of the function in the background script
// Re-implementation of the function in the background script
async function getAPIKey(forceGetAllDefaultKeys, useAPIKeyAtIndex = null) {
// List of API keys that are stored in the database/locally
let availableAPIKeys;
Expand Down
Loading