mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-11 09:30:46 +01:00
Merge pull request #212 from ajayyy/experimental-ajay
UserID import, ID fixes, view count fix, embed error fix
This commit is contained in:
commit
1abc1b9b28
6 changed files with 71 additions and 15 deletions
|
@ -320,5 +320,17 @@
|
||||||
},
|
},
|
||||||
"statusReminder": {
|
"statusReminder": {
|
||||||
"message": "Check status.sponsor.ajay.app for server status."
|
"message": "Check status.sponsor.ajay.app for server status."
|
||||||
|
},
|
||||||
|
"changeUserID": {
|
||||||
|
"message": "Import/Export Your UserID"
|
||||||
|
},
|
||||||
|
"whatChangeUserID": {
|
||||||
|
"message": "This should be kept private. This is like a password and should not be shared with anyone. If someone has this, they can impersonate you."
|
||||||
|
},
|
||||||
|
"setUserID": {
|
||||||
|
"message": "Set UserID"
|
||||||
|
},
|
||||||
|
"userIDChangeWarning": {
|
||||||
|
"message": "Warning: Changing the UserID is permanent. Are you sure you would like to do this? Make sure to backup your old one just in case."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ function submitVote(type, UUID, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//publish this vote
|
//publish this vote
|
||||||
sendRequestToServer("GET", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
|
sendRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
callback({
|
callback({
|
||||||
successType: 1
|
successType: 1
|
||||||
|
|
17
content.js
17
content.js
|
@ -498,12 +498,11 @@ function updatePreviewBar() {
|
||||||
|
|
||||||
function getChannelID() {
|
function getChannelID() {
|
||||||
//get channel id
|
//get channel id
|
||||||
let channelNameContainer = document.getElementById("channel-name");
|
|
||||||
|
|
||||||
let channelURLContainer = null;
|
let channelURLContainer = null;
|
||||||
|
|
||||||
if (channelNameContainer !== null) {
|
channelURLContainer = document.querySelector("#channel-name > #container > #text-container > #text");
|
||||||
channelURLContainer = channelNameContainer.querySelector("#container").querySelector("#text-container").querySelector("#text").firstElementChild;
|
if (channelURLContainer !== null) {
|
||||||
|
channelURLContainer = channelURLContainer.firstElementChild;
|
||||||
} else {
|
} else {
|
||||||
//old YouTube theme
|
//old YouTube theme
|
||||||
let channelContainers = document.getElementsByClassName("yt-user-info");
|
let channelContainers = document.getElementsByClassName("yt-user-info");
|
||||||
|
@ -652,9 +651,9 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//send telemetry that a this sponsor was skipped happened
|
//send telemetry that a this sponsor was skipped
|
||||||
if (trackViewCount && !sponsorSkipped[index]) {
|
if (trackViewCount && !sponsorSkipped[index]) {
|
||||||
sendRequestToServer("GET", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
|
sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
|
||||||
|
|
||||||
if (!disableAutoSkip) {
|
if (!disableAutoSkip) {
|
||||||
// Count this as a skip
|
// Count this as a skip
|
||||||
|
@ -941,11 +940,13 @@ function vote(type, UUID, skipNotice) {
|
||||||
|
|
||||||
let sponsorIndex = UUIDs.indexOf(UUID);
|
let sponsorIndex = UUIDs.indexOf(UUID);
|
||||||
|
|
||||||
// See if the local time saved count and skip count should be reverted
|
// See if the local time saved count and skip count should be saved
|
||||||
if (type == 0 && sponsorSkipped[sponsorIndex] || type == 1 && !sponsorSkipped[sponsorIndex]) {
|
if (type == 0 && sponsorSkipped[sponsorIndex] || type == 1 && !sponsorSkipped[sponsorIndex]) {
|
||||||
let factor = 1;
|
let factor = 1;
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
factor = -1;
|
factor = -1;
|
||||||
|
|
||||||
|
sponsorSkipped[sponsorIndex] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count this as a skip
|
// Count this as a skip
|
||||||
|
@ -959,8 +960,6 @@ function vote(type, UUID, skipNotice) {
|
||||||
|
|
||||||
chrome.storage.sync.set({"skipCount": result.skipCount + factor * 1 });
|
chrome.storage.sync.set({"skipCount": result.skipCount + factor * 1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
sponsorSkipped[sponsorIndex] = !sponsorSkipped[sponsorIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "__MSG_Name__",
|
"short_name": "__MSG_Name__",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
|
|
22
popup.html
22
popup.html
|
@ -253,6 +253,28 @@
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
<button id="changeUserIDButton" class="warningButton popupElement">__MSG_changeUserID__</button>
|
||||||
|
<br/>
|
||||||
|
<sub class="popupElement">
|
||||||
|
__MSG_whatChangeUserID__
|
||||||
|
</sub>
|
||||||
|
|
||||||
|
<div id="changeUserID" class="popupElement" style="display: none">
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<input id="userIDInput" hint="userID"></input>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<button id="setUserID" class="warningButton popupElement">__MSG_setUserID__</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<button id="disableSponsorViewTracking" class="warningButton popupElement">__MSG_disableViewTracking__</button>
|
<button id="disableSponsorViewTracking" class="warningButton popupElement">__MSG_disableViewTracking__</button>
|
||||||
<button id="enableSponsorViewTracking" style="display: none" class="warningButton popupElement">__MSG_enableViewTracking__</button>
|
<button id="enableSponsorViewTracking" style="display: none" class="warningButton popupElement">__MSG_enableViewTracking__</button>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
31
popup.js
31
popup.js
|
@ -82,6 +82,11 @@ function runThePopup() {
|
||||||
"setUsername",
|
"setUsername",
|
||||||
"usernameInput",
|
"usernameInput",
|
||||||
"submitUsername",
|
"submitUsername",
|
||||||
|
// UserID
|
||||||
|
"changeUserID",
|
||||||
|
"changeUserIDButton",
|
||||||
|
"userIDInput",
|
||||||
|
"setUserID",
|
||||||
// More
|
// More
|
||||||
"submissionSection",
|
"submissionSection",
|
||||||
"mainControls",
|
"mainControls",
|
||||||
|
@ -118,6 +123,8 @@ function runThePopup() {
|
||||||
SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking);
|
SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking);
|
||||||
SB.setUsernameButton.addEventListener("click", setUsernameButton);
|
SB.setUsernameButton.addEventListener("click", setUsernameButton);
|
||||||
SB.submitUsername.addEventListener("click", submitUsername);
|
SB.submitUsername.addEventListener("click", submitUsername);
|
||||||
|
SB.changeUserIDButton.addEventListener("click", changeUserIDButton);
|
||||||
|
SB.setUserID.addEventListener("click", setUserID);
|
||||||
SB.optionsButton.addEventListener("click", openOptions);
|
SB.optionsButton.addEventListener("click", openOptions);
|
||||||
SB.reportAnIssue.addEventListener("click", reportAnIssue);
|
SB.reportAnIssue.addEventListener("click", reportAnIssue);
|
||||||
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);
|
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);
|
||||||
|
@ -740,8 +747,8 @@ function runThePopup() {
|
||||||
tabs[0].id,
|
tabs[0].id,
|
||||||
{message: "getCurrentTime"},
|
{message: "getCurrentTime"},
|
||||||
function (response) {
|
function (response) {
|
||||||
let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index);
|
let minutes = document.getElementById(idStartName + "Minutes" + index);
|
||||||
let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index);
|
let seconds = document.getElementById(idStartName + "Seconds" + index);
|
||||||
|
|
||||||
minutes.value = getTimeInMinutes(response.currentTime);
|
minutes.value = getTimeInMinutes(response.currentTime);
|
||||||
seconds.value = getTimeInFormattedSeconds(response.currentTime);
|
seconds.value = getTimeInFormattedSeconds(response.currentTime);
|
||||||
|
@ -752,8 +759,8 @@ function runThePopup() {
|
||||||
//id start name is whether it is the startTime or endTime
|
//id start name is whether it is the startTime or endTime
|
||||||
//gives back the time in seconds
|
//gives back the time in seconds
|
||||||
function getSponsorTimeEditTimes(idStartName, index) {
|
function getSponsorTimeEditTimes(idStartName, index) {
|
||||||
let minutes = document.getElementById(idStartName + chrome.i18n.getMessage("Mins") + index);
|
let minutes = document.getElementById(idStartName + "Minutes" + index);
|
||||||
let seconds = document.getElementById(idStartName + chrome.i18n.getMessage("Secs") + index);
|
let seconds = document.getElementById(idStartName + "Seconds" + index);
|
||||||
|
|
||||||
return parseInt(minutes.value) * 60 + parseFloat(seconds.value);
|
return parseInt(minutes.value) * 60 + parseFloat(seconds.value);
|
||||||
}
|
}
|
||||||
|
@ -1158,6 +1165,22 @@ function runThePopup() {
|
||||||
SB.setUsernameContainer.style.display = "none";
|
SB.setUsernameContainer.style.display = "none";
|
||||||
SB.setUsername.style.display = "unset";
|
SB.setUsername.style.display = "unset";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeUserIDButton() {
|
||||||
|
//get the user ID
|
||||||
|
chrome.storage.sync.get(["userID"], function(result) {
|
||||||
|
SB.userIDInput.value = result.userID;
|
||||||
|
SB.setUserID.style.display = "unset";
|
||||||
|
SB.userIDInput.style.display = "unset";
|
||||||
|
SB.changeUserID.style.display = "unset";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUserID() {
|
||||||
|
if (!confirm(chrome.i18n.getMessage("userIDChangeWarning"))) return;
|
||||||
|
|
||||||
|
chrome.storage.sync.set({"userID": SB.userIDInput.value});
|
||||||
|
}
|
||||||
|
|
||||||
//this is not a YouTube video page
|
//this is not a YouTube video page
|
||||||
function displayNoVideo() {
|
function displayNoVideo() {
|
||||||
|
|
Loading…
Reference in a new issue