Compare commits

...

7 Commits

Author SHA1 Message Date
Ajay Ramachandran
d97d45ae14 Remove some redundant checks 2021-07-06 01:39:05 -04:00
Ajay Ramachandran
b066945331 Use segment count from the API 2021-07-06 01:35:39 -04:00
Ajay Ramachandran
584cfd4ff8 Add lock button shown for VIPs 2021-07-06 01:33:06 -04:00
Ajay Ramachandran
069ae4bb58 Add issue assigning action 2021-07-05 20:50:59 -04:00
Ajay Ramachandran
7f8947dd0a Add refresh segments button 2021-07-04 16:12:41 -04:00
Ajay Ramachandran
0ae34c9603 Update more packages 2021-07-04 15:01:33 -04:00
Ajay Ramachandran
41a3c695dc Update packages 2021-07-04 14:35:46 -04:00
12 changed files with 24614 additions and 4348 deletions

14
.github/workflows/take-action.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
# .github/workflows/take.yml
name: Assign issue to contributor
on:
issue_comment:
jobs:
assign:
name: Take an issue
runs-on: ubuntu-latest
steps:
- name: take the issue
uses: bdougie/take-action@main
env:
GITHUB_TOKEN: ${{ github.token }}

View File

@@ -40,6 +40,8 @@
"icons/help.svg",
"icons/report.png",
"icons/close.png",
"icons/refresh.svg",
"icons/lock.svg",
"icons/beep.ogg",
"icons/PlayerInfoIconSponsorBlocker.svg",
"icons/PlayerDeleteIconSponsorBlocker.svg",

28763
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -24,12 +24,12 @@
"copy-webpack-plugin": "^6.0.3",
"eslint": "^7.15.0",
"eslint-plugin-react": "^7.21.5",
"jest": "^26.4.0",
"jest": "^27.0.6",
"rimraf": "^3.0.0",
"ts-jest": "^26.2.0",
"ts-jest": "^27.0.3",
"ts-loader": "^6.2.1",
"typescript": "~3.7.3",
"web-ext": "^5.4.1",
"typescript": "~4.3",
"web-ext": "^6.2.0",
"webpack": "~4.41.2",
"webpack-cli": "~3.3.10",
"webpack-merge": "~4.2.2"

View File

@@ -85,6 +85,9 @@
"noVideoID": {
"message": "No YouTube video found.\nIf this is incorrect, refresh the tab."
},
"refreshSegments": {
"message": "Refresh segments"
},
"success": {
"message": "Success!"
},

1
public/icons/lock.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><g fill="none"><path d="M0 0h24v24H0V0z"/><path d="M0 0h24v24H0V0z" opacity=".87"/></g><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"/></svg>

After

Width:  |  Height:  |  Size: 426 B

1
public/icons/refresh.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>

After

Width:  |  Height:  |  Size: 361 B

View File

@@ -259,7 +259,7 @@ background-color:#ec1c1c;
align-items: center;
}
#additionalButtons>button, button#setUsernameButton, #submitUsername {
.sbSlimButton, #additionalButtons>button, button#setUsernameButton, #submitUsername {
background: none;
border: none;
color: white;
@@ -321,12 +321,12 @@ label>p, #disableExtension>p, #usernameValue, #usernameElement > div > p,#sponso
margin-right: 8px;
}
#whitelistButton>label, #additionalButtons>button, div#setUsernameContainer {
#whitelistButton>label, #additionalButtons>button, div#setUsernameContainer>button {
display: flex;
flex-flow: row nowrap;
}
#whitelistButton>label, #additionalButtons>button, div#setUsernameContainer>button {
.sbSlimButton, #whitelistButton>label, #additionalButtons>button, div#setUsernameContainer>button {
cursor: pointer;
}

View File

@@ -18,6 +18,12 @@
<p id="loadingIndicator">__MSG_noVideoID__</p>
<!-- If the video was found in the database -->
<p id="videoFound"></p>
<button class="sbSlimButton" id="refreshSegmentsButton" title="__MSG_refreshSegments__">
<img id="refreshSegments" src="/icons/refresh.svg"/>
</button>
<button class="sbSlimButton hidden" id="lockSegmentsButton">
<img id="LockSegments" src="/icons/lock.svg"/>
</button>
</div>
<div id="issueReporterContainer">
<div id="issueReporterTimeButtons"></div>

View File

@@ -178,6 +178,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
case "submitTimes":
submitSponsorTimes();
break;
case "refreshSegments":
sponsorsLookup(sponsorVideoID, false);
break;
}
}
@@ -209,6 +212,7 @@ function resetValues() {
//reset sponsor times
sponsorTimes = null;
sponsorLookupRetries = 0;
sponsorSkipped = [];
videoInfo = null;
channelWhitelisted = false;
@@ -569,7 +573,7 @@ function setupVideoListeners() {
}
}
async function sponsorsLookup(id: string) {
async function sponsorsLookup(id: string, keepOldSubmissions = true) {
if (!video) refreshVideoAttachments();
//there is still no video here
if (!video) {
@@ -606,7 +610,7 @@ async function sponsorsLookup(id: string) {
sponsorDataFound = true;
// Check if any old submissions should be kept
if (sponsorTimes !== null) {
if (sponsorTimes !== null && keepOldSubmissions) {
for (let i = 0; i < sponsorTimes.length; i++) {
if (sponsorTimes[i].source === SponsorSourceType.Local) {
// This is a user submission, keep it
@@ -627,20 +631,19 @@ async function sponsorsLookup(id: string) {
}
}
for (const segment of oldSegments) {
const otherSegment = sponsorTimes.find((other) => segment.UUID === other.UUID);
if (otherSegment) {
// If they downvoted it, or changed the category, keep it
otherSegment.hidden = segment.hidden;
otherSegment.category = segment.category;
if (keepOldSubmissions) {
for (const segment of oldSegments) {
const otherSegment = sponsorTimes.find((other) => segment.UUID === other.UUID);
if (otherSegment) {
// If they downvoted it, or changed the category, keep it
otherSegment.hidden = segment.hidden;
otherSegment.category = segment.category;
}
}
}
startSkipScheduleCheckingForStartSponsors();
// Reset skip save
sponsorSkipped = [];
//update the preview bar
//leave the type blank for now until categories are added
if (lastPreviewBarUpdate == id || (lastPreviewBarUpdate == null && !isNaN(video.duration))) {
@@ -1408,11 +1411,14 @@ function openInfoMenu() {
const settings = <HTMLImageElement> popup.querySelector("#sbPopupIconSettings");
const edit = <HTMLImageElement> popup.querySelector("#sbPopupIconEdit");
const check = <HTMLImageElement> popup.querySelector("#sbPopupIconCheck");
const refreshSegments = <HTMLImageElement> popup.querySelector("#refreshSegments");
const lockSegments = <HTMLImageElement> popup.querySelector("#lockSegments");
logo.src = chrome.extension.getURL("icons/IconSponsorBlocker256px.png");
settings.src = chrome.extension.getURL("icons/settings.svg");
edit.src = chrome.extension.getURL("icons/pencil.svg");
check.src = chrome.extension.getURL("icons/check.svg");
check.src = chrome.extension.getURL("icons/thumb.svg");
refreshSegments.src = chrome.extension.getURL("icons/refresh.svg");
lockSegments.src = chrome.extension.getURL("icons/lock.svg");
parentNode.insertBefore(popup, parentNode.firstChild);

View File

@@ -16,7 +16,8 @@ interface DefaultMessage {
| "getVideoID"
| "getChannelID"
| "isChannelWhitelisted"
| "submitTimes";
| "submitTimes"
| "refreshSegments";
}
interface BoolValueMessage {

View File

@@ -102,6 +102,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
"videoFound",
"sponsorMessageTimes",
//"downloadedSponsorMessageTimes",
"refreshSegmentsButton",
"lockSegmentsButton",
"whitelistButton",
"sbDonate"
].forEach(id => PageElements[id] = document.getElementById(id));
@@ -131,6 +133,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
PageElements.submitUsername.addEventListener("click", submitUsername);
PageElements.optionsButton.addEventListener("click", openOptions);
PageElements.helpButton.addEventListener("click", openHelp);
PageElements.refreshSegmentsButton.addEventListener("click", refreshSegments);
PageElements.lockSegmentsButton.addEventListener("click", lockSegments);
/** If true, the content script is in the process of creating a new segment. */
let creatingSegment = false;
@@ -142,93 +146,68 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
let currentVideoID = null;
//show proper disable skipping button
const disableSkipping = Config.config.disableSkipping;
if (disableSkipping != undefined && disableSkipping) {
if (Config.config.disableSkipping) {
PageElements.disableSkipping.style.display = "none";
PageElements.enableSkipping.style.display = "unset";
PageElements.toggleSwitch.checked = false;
}
//if the don't show notice again variable is true, an option to
// disable should be available
const dontShowNotice = Config.config.dontShowNotice;
if (dontShowNotice != undefined && dontShowNotice) {
if (Config.config.dontShowNotice) {
PageElements.showNoticeAgain.style.display = "unset";
}
utils.sendRequestToServer("GET", "/api/getUsername?userID=" + Config.config.userID, (res) => {
if (res.status === 200) {
PageElements.usernameValue.innerText = JSON.parse(res.responseText).userName
}
})
const userInfoRes = await utils.asyncRequestToServer("GET", "/api/userInfo?userID=" + Config.config.userID);
if (userInfoRes.ok) {
const userInfo = JSON.parse(userInfoRes.responseText);
//get the amount of times this user has contributed and display it to thank them
if (Config.config.sponsorTimesContributed != undefined) {
PageElements.sponsorTimesContributionsDisplay.innerText = Config.config.sponsorTimesContributed.toLocaleString();
if (userInfo.vip) PageElements.lockSegmentsButton.classList.remove("hidden");
PageElements.usernameValue.innerText = userInfo.userName;
PageElements.sponsorTimesContributionsDisplay.innerText = userInfo.segmentCount.toLocaleString();
PageElements.sponsorTimesContributionsContainer.classList.remove("hidden");
//get the userID
const userID = Config.config.userID;
if (userID != undefined) {
//there are probably some views on these submissions then
//get the amount of views from the sponsors submitted
utils.sendRequestToServer("GET", "/api/getViewsForUser?userID=" + userID, function(response) {
if (response.status == 200) {
const viewCount = JSON.parse(response.responseText).viewCount;
if (viewCount != 0) {
if (viewCount > 1) {
PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments");
} else {
PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment");
}
const viewCount = userInfo.viewCount;
if (viewCount != 0) {
if (viewCount > 1) {
PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments");
} else {
PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment");
}
PageElements.sponsorTimesViewsDisplay.innerText = viewCount.toLocaleString();
PageElements.sponsorTimesViewsContainer.style.display = "unset";
}
}
});
PageElements.sponsorTimesViewsDisplay.innerText = viewCount.toLocaleString();
PageElements.sponsorTimesViewsContainer.style.display = "unset";
}
//get this time in minutes
utils.sendRequestToServer("GET", "/api/getSavedTimeForUser?userID=" + userID, function(response) {
if (response.status == 200) {
const minutesSaved = JSON.parse(response.responseText).timeSaved;
if (minutesSaved != 0) {
if (minutesSaved != 1) {
PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else {
PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
}
const minutesSaved = userInfo.minutesSaved;
if (minutesSaved != 0) {
if (minutesSaved != 1) {
PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else {
PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
}
PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
}
}
});
PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
}
}
//get the amount of times this user has skipped a sponsor
if (Config.config.skipCount != undefined) {
if (Config.config.skipCount != 1) {
PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Segments");
} else {
PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Segment");
}
PageElements.sponsorTimesSkipsDoneDisplay.innerText = Config.config.skipCount.toLocaleString();
PageElements.sponsorTimesSkipsDoneContainer.style.display = "unset";
if (Config.config.skipCount != 1) {
PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Segments");
} else {
PageElements.sponsorTimesSkipsDoneEndWord.innerText = chrome.i18n.getMessage("Segment");
}
//get the amount of time this user has saved.
if (Config.config.minutesSaved != undefined) {
if (Config.config.minutesSaved != 1) {
PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else {
PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
}
PageElements.sponsorTimesSkipsDoneDisplay.innerText = Config.config.skipCount.toLocaleString();
PageElements.sponsorTimesSkipsDoneContainer.style.display = "unset";
PageElements.sponsorTimeSavedDisplay.innerText = getFormattedHours(Config.config.minutesSaved);
if (Config.config.minutesSaved != 1) {
PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
} else {
PageElements.sponsorTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower");
}
PageElements.sponsorTimeSavedDisplay.innerText = getFormattedHours(Config.config.minutesSaved);
// Must be delayed so it only happens once loaded
setTimeout(() => PageElements.sponsorblockPopup.classList.remove("preload"), 250);
@@ -676,6 +655,22 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
});
}
function refreshSegments() {
messageHandler.query({
active: true,
currentWindow: true
}, tabs => {
messageHandler.sendMessage(
tabs[0].id,
{message: 'refreshSegments'}
)}
);
}
function lockSegments() {
alert("lock");
}
/**
* Should skipping be disabled (visuals stay)
*/