mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-14 07:27:05 +03:00
Kind of better :/
This commit is contained in:
@@ -269,8 +269,7 @@ function getYouTubeVideoID(url) { // Return video id or false
|
|||||||
return (match && match[7].length == 11) ? match[7] : false;
|
return (match && match[7].length == 11) ? match[7] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateUUID() {
|
function generateUUID(length = 36) {
|
||||||
var length = 36;
|
|
||||||
var charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
var i;
|
var i;
|
||||||
var result = "";
|
var result = "";
|
||||||
@@ -282,14 +281,11 @@ function generateUUID() {
|
|||||||
result += charset[values[i] % charset.length];
|
result += charset[values[i] % charset.length];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else if (isOpera) //Opera's Math.random is secure, see http://lists.w3.org/Archives/Public/public-webcrypto/2013Jan/0063.html
|
} else {
|
||||||
{
|
if(!isOpera) alert("[SB] Your browser can't generate a secure userID");
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
result += charset[Math.floor(Math.random() * charset.length)];
|
result += charset[Math.floor(Math.random() * charset.length)];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
|
||||||
alert("Your browser can't generate a secure UUID so Math.random() was used");
|
|
||||||
return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user