Skip to content

Commit

Permalink
Merge SB v5.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Mar 30, 2024
1 parent d54c37a commit 5fda9cc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 40 deletions.
2 changes: 1 addition & 1 deletion maze-utils
2 changes: 1 addition & 1 deletion public/_locales
12 changes: 12 additions & 0 deletions public/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ <h2>__MSG_exportOtherData__</h2>
<div class="small-description">__MSG_whatTrackDownvotes__</div>
</div>

<div data-type="toggle" data-sync="trackDownvotesInPrivate" data-confirm-on="false">
<div class="switch-container">
<label class="switch">
<input id="trackDownvotesInPrivate" type="checkbox" checked>
<span class="slider round"></span>
</label>
<label class="switch-label" for="trackDownvotesInPrivate">
__MSG_enableTrackDownvotesInPrivate__
</label>
</div>
</div>

<div data-type="button-press" data-sync="copyDebugInformation" data-confirm-message="copyDebugInformation">
<div class="option-button trigger-button">
__MSG_copyDebugInformation__
Expand Down
2 changes: 1 addition & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async function submitVote(type: number, UUID: string, category: string) {

try {
const response = await asyncRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + typeSection);

if (response.ok) {
return {
successType: 1,
Expand Down
68 changes: 36 additions & 32 deletions src/components/SponsorTimeEditComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,43 +244,47 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo

{/* Editing Tools */}

<span id={"sponsorTimeDeleteButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={this.deleteTime.bind(this)}>
{chrome.i18n.getMessage("delete")}
</span>

{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType)) ? (
<span id={"sponsorTimePreviewButton" + this.idSuffix}
<div style={{ marginTop: "3px" }}>
<span id={"sponsorTimeDeleteButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
{chrome.i18n.getMessage("preview")}
onClick={this.deleteTime.bind(this)}>
{chrome.i18n.getMessage("delete")}
</span>
): ""}

{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
<span id={"sponsorTimeInspectButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={this.inspectTime.bind(this)}>
{chrome.i18n.getMessage("inspect")}
</span>
): ""}
{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType))
? (
<span id={"sponsorTimePreviewButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
{chrome.i18n.getMessage("preview")}
</span>
): ""}

{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType)) ? (
<span id={"sponsorTimePreviewEndButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey, true)}>
{chrome.i18n.getMessage("End")}
</span>
): ""}
{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
<span id={"sponsorTimeInspectButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={this.inspectTime.bind(this)}>
{chrome.i18n.getMessage("inspect")}
</span>
): ""}

{(!isNaN(segment[1]) && ![ActionType.Poi, ActionType.Full].includes(this.state.selectedActionType)) ? (
<span id={"sponsorTimePreviewEndButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey, true)}>
{chrome.i18n.getMessage("End")}
</span>
): ""}

{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
<span id={"sponsorTimeEditButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={this.toggleEditTime.bind(this)}>
{this.state.editing ? chrome.i18n.getMessage("save") : chrome.i18n.getMessage("edit")}
</span>
): ""}
</div>

{(!isNaN(segment[1]) && this.state.selectedActionType != ActionType.Full) ? (
<span id={"sponsorTimeEditButton" + this.idSuffix}
className="sponsorTimeEditButton"
onClick={this.toggleEditTime.bind(this)}>
{this.state.editing ? chrome.i18n.getMessage("save") : chrome.i18n.getMessage("edit")}
</span>
): ""}
</div>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface SBConfig {
trackViewCount: boolean;
trackViewCountInPrivate: boolean;
trackDownvotes: boolean;
trackDownvotesInPrivate: boolean;
dontShowNotice: boolean;
noticeVisibilityMode: NoticeVisbilityMode;
hideVideoPlayerControls: boolean;
Expand Down Expand Up @@ -273,6 +274,7 @@ const syncDefaults = {
trackViewCount: true,
trackViewCountInPrivate: true,
trackDownvotes: true,
trackDownvotesInPrivate: false,
dontShowNotice: false,
noticeVisibilityMode: NoticeVisbilityMode.FadedForAutoSkip,
hideVideoPlayerControls: false,
Expand Down
3 changes: 2 additions & 1 deletion src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,8 @@ async function sendSubmitMessage(): Promise<boolean> {
if (!previewedSegment
&& !sponsorTimesSubmitting.every((segment) =>
[ActionType.Full, ActionType.Poi].includes(segment.actionType)
|| segment.segment[1] >= getVideo()?.duration)) {
|| segment.segment[1] >= getVideo()?.duration
|| segment.segment[0] === 0)) {
alert(`${chrome.i18n.getMessage("previewSegmentRequired")} ${keybindToString(Config.config.previewKeybind)}`);
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async function init() {
break;
case "resetToDefault":
Config.resetToDefault();
window.location.reload();
setTimeout(() => window.location.reload(), 200);
break;
}
});
Expand Down Expand Up @@ -564,8 +564,7 @@ async function setTextOption(option: string, element: HTMLElement, value: string
}
}

window.location.reload();

setTimeout(() => window.location.reload(), 200);
} catch (e) {
alert(chrome.i18n.getMessage("incorrectlyFormattedOptions"));
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ export default class Utils {
}

async addHiddenSegment(videoID: VideoID, segmentUUID: string, hidden: SponsorHideType) {
if (chrome.extension.inIncognitoContext || !Config.config.trackDownvotes) return;
if ((chrome.extension.inIncognitoContext && !Config.config.trackDownvotesInPrivate)
|| !Config.config.trackDownvotes) return;

const hashedVideoID = (await getHash(videoID, 1)).slice(0, 4) as VideoID & HashedValue;
const UUIDHash = await getHash(segmentUUID, 1);
Expand Down

0 comments on commit 5fda9cc

Please sign in to comment.