aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-22 16:10:50 -0400
committerGitHub <[email protected]>2019-08-22 16:10:50 -0400
commitd1f1f9213efaee0bf860d6bb7fcab9e22c639887 (patch)
tree45f09a5fc8b6eb3700c224977b9e67ecb827bcef
parent0ae3820681764c4d33bb26674f9d025e283fae22 (diff)
parentd498c107a8e4cab1a13c8e11126f8f7afd13c7dd (diff)
downloadSponsorBlock-1.1.3.tar.gz
SponsorBlock-1.1.3.zip
Merge pull request #129 from ajayyy/experimental-ajay1.1.3
UserID undefined checks
-rw-r--r--background.js19
-rw-r--r--content.js8
-rw-r--r--manifest.json2
3 files changed, 20 insertions, 9 deletions
diff --git a/background.js b/background.js
index afbe1644..64c7813c 100644
--- a/background.js
+++ b/background.js
@@ -56,7 +56,6 @@ chrome.runtime.onInstalled.addListener(function (object) {
// TODO (shownInstallPage): remove this if statement, but leave contents
if (!shownInstallPage){
//open up the install page
-
chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))});
}
@@ -67,13 +66,10 @@ chrome.runtime.onInstalled.addListener(function (object) {
}
//generate a userID
- const newUserID = generateUUID();
+ const newUserID = generateUserID();
//save this UUID
chrome.storage.sync.set({
- "userID": newUserID,
- //the last video id loaded, to make sure it is a video id change
- "sponsorVideoID": null,
- "previousVideoID": null
+ "userID": newUserID
});
}
});
@@ -117,6 +113,14 @@ function submitVote(type, UUID, callback) {
chrome.storage.sync.get(["userID"], function(result) {
let userID = result.userID;
+ if (userID == undefined || userID === "undefined") {
+ //generate one
+ userID = generateUserID();
+ chrome.storage.sync.set({
+ "userID": userID
+ });
+ }
+
//publish this vote
sendRequestToServer("GET", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
@@ -201,10 +205,9 @@ function sendRequestToServer(type, address, callback) {
xmlhttp.send();
}
-function generateUUID(length = 36) {
+function generateUserID(length = 36) {
let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let result = "";
- let isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
if (window.crypto && window.crypto.getRandomValues) {
values = new Uint32Array(length);
window.crypto.getRandomValues(values);
diff --git a/content.js b/content.js
index 0cd02940..e88b602b 100644
--- a/content.js
+++ b/content.js
@@ -548,12 +548,14 @@ function addPlayerControlsButton() {
let startSponsorButton = document.createElement("button");
startSponsorButton.id = "startSponsorButton";
+ startSponsorButton.draggable = false;
startSponsorButton.className = "ytp-button playerButton";
startSponsorButton.setAttribute("title", chrome.i18n.getMessage("sponsorStart"));
startSponsorButton.addEventListener("click", startSponsorClicked);
let startSponsorImage = document.createElement("img");
startSponsorImage.id = "startSponsorImage";
+ startSponsorImage.draggable = false;
startSponsorImage.className = "playerButtonImage";
startSponsorImage.src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
@@ -675,12 +677,14 @@ function addInfoButton() {
//make a submit button
let infoButton = document.createElement("button");
infoButton.id = "infoButton";
+ infoButton.draggable = false;
infoButton.className = "ytp-button playerButton";
infoButton.setAttribute("title", "Open SponsorBlock Popup");
infoButton.addEventListener("click", openInfoMenu);
let infoImage = document.createElement("img");
infoImage.id = "infoButtonImage";
+ infoImage.draggable = false;
infoImage.className = "playerButtonImage";
infoImage.src = chrome.extension.getURL("icons/PlayerInfoIconSponsorBlocker256px.png");
@@ -709,6 +713,7 @@ function addDeleteButton() {
//make a submit button
let deleteButton = document.createElement("button");
deleteButton.id = "deleteButton";
+ deleteButton.draggable = false;
deleteButton.className = "ytp-button playerButton";
deleteButton.setAttribute("title", "Clear Sponsor Times");
deleteButton.addEventListener("click", clearSponsorTimes);
@@ -717,6 +722,7 @@ function addDeleteButton() {
let deleteImage = document.createElement("img");
deleteImage.id = "deleteButtonImage";
+ deleteImage.draggable = false;
deleteImage.className = "playerButtonImage";
deleteImage.src = chrome.extension.getURL("icons/PlayerDeleteIconSponsorBlocker256px.png");
@@ -745,6 +751,7 @@ function addSubmitButton() {
//make a submit button
let submitButton = document.createElement("button");
submitButton.id = "submitButton";
+ submitButton.draggable = false;
submitButton.className = "ytp-button playerButton";
submitButton.setAttribute("title", "Submit Sponsor Times");
submitButton.addEventListener("click", submitSponsorTimes);
@@ -753,6 +760,7 @@ function addSubmitButton() {
let submitImage = document.createElement("img");
submitImage.id = "submitButtonImage";
+ submitImage.draggable = false;
submitImage.className = "playerButtonImage";
submitImage.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
diff --git a/manifest.json b/manifest.json
index 427e063c..230d1412 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_fullName__",
"short_name": "__MSG_Name__",
- "version": "1.1.2",
+ "version": "1.1.3",
"default_locale": "en",
"description": "__MSG_Description__",
"content_scripts": [