mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Fixed new submissions getting added to the downloaded submissions.
This commit is contained in:
@@ -216,21 +216,3 @@ function sendRequestToServer(type, address, callback) {
|
||||
//submit this request
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
function generateUserID(length = 36) {
|
||||
let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
if (window.crypto && window.crypto.getRandomValues) {
|
||||
values = new Uint32Array(length);
|
||||
window.crypto.getRandomValues(values);
|
||||
for (i = 0; i < length; i++) {
|
||||
result += charset[values[i] % charset.length];
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += charset[Math.floor(Math.random() * charset.length)];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
15
content.js
15
content.js
@@ -1041,6 +1041,9 @@ function submitSponsorTimes() {
|
||||
//update sponsorTimes
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
|
||||
|
||||
//update sponsorTimesSubmitting
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
|
||||
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes)
|
||||
+ "\n\n" + chrome.i18n.getMessage("confirmMSG") + "\n\n" + chrome.i18n.getMessage("guildlinesSummary");
|
||||
if(!confirm(confirmMessage)) return;
|
||||
@@ -1060,8 +1063,6 @@ function sendSubmitMessage(){
|
||||
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
let currentSponsorTimes = submitSponsorTimes;
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitTimes",
|
||||
videoID: currentVideoID
|
||||
@@ -1085,11 +1086,19 @@ function sendSubmitMessage(){
|
||||
|
||||
//clear the sponsor times
|
||||
let sponsorTimeKey = "sponsorTimes" + currentVideoID;
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: []}, () => void updatePreviewBar());
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: []});
|
||||
|
||||
//add submissions to current sponsors list
|
||||
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
|
||||
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
|
||||
// Add some random IDs
|
||||
UUIDs.push(generateUserID());
|
||||
}
|
||||
|
||||
// Empty the submitting times
|
||||
sponsorTimesSubmitting = [];
|
||||
|
||||
updatePreviewBar();
|
||||
} else {
|
||||
//show that the upload failed
|
||||
document.getElementById("submitButton").style.animation = "unset";
|
||||
|
||||
18
utils.js
18
utils.js
@@ -66,6 +66,24 @@ function localizeHtmlPage() {
|
||||
}
|
||||
}
|
||||
|
||||
function generateUserID(length = 36) {
|
||||
let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
if (window.crypto && window.crypto.getRandomValues) {
|
||||
values = new Uint32Array(length);
|
||||
window.crypto.getRandomValues(values);
|
||||
for (i = 0; i < length; i++) {
|
||||
result += charset[values[i] % charset.length];
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += charset[Math.floor(Math.random() * charset.length)];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error message in a nice string
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user