mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85b70f8ad7 | ||
|
|
3e32f28d2e | ||
|
|
9bd1b03504 | ||
|
|
cdccc43b31 | ||
|
|
21ce614bd9 | ||
|
|
7f56ec238f | ||
|
|
e1625437d4 | ||
|
|
5b9afebd4e | ||
|
|
93afc06717 | ||
|
|
cfbf1f8995 | ||
|
|
516e5077a9 | ||
|
|
0c2ceb134b | ||
|
|
02bcb0b213 | ||
|
|
35c6ed81b5 | ||
|
|
a229aee2cc | ||
|
|
f91c6d5f9d | ||
|
|
0e93fb6f57 | ||
|
|
1f491d2031 | ||
|
|
32dd7d43d7 | ||
|
|
284efe9902 | ||
|
|
4e795c8fb1 | ||
|
|
c83eb589ea | ||
|
|
7cd6b324b9 | ||
|
|
5891fccacb | ||
|
|
59233f3307 | ||
|
|
796466a72a | ||
|
|
3f35642010 | ||
|
|
5bbfcf742d | ||
|
|
aaf79fda0d | ||
|
|
8604788d27 | ||
|
|
519a822751 | ||
|
|
fef31c399b | ||
|
|
5802e05228 | ||
|
|
da21081a12 | ||
|
|
6d739de57c | ||
|
|
edcd328743 | ||
|
|
5c9e6cac0e | ||
|
|
7ab5e2cf52 | ||
|
|
42dcdb40cf | ||
|
|
896357a943 | ||
|
|
2d96c24b13 | ||
|
|
1753f58120 | ||
|
|
7244ca8f5e | ||
|
|
ec0c989066 | ||
|
|
c801b1fecd | ||
|
|
57b50106d1 | ||
|
|
871ba63f67 | ||
|
|
f0888faf78 | ||
|
|
23fbbebc9e | ||
|
|
9951a19478 | ||
|
|
dd4ab2f38a | ||
|
|
6bcdb3e272 | ||
|
|
227bec4d8e | ||
|
|
556b4f88d2 | ||
|
|
2d12f957bc | ||
|
|
c1efe02614 | ||
|
|
f0e1979aab | ||
|
|
989db6d6b6 | ||
|
|
781096c290 | ||
|
|
536c6e3e41 | ||
|
|
de376176db | ||
|
|
e63389cfa3 | ||
|
|
1c4ca8da26 | ||
|
|
dcbd7ba4cd | ||
|
|
9fc8d385ab | ||
|
|
07e878e065 | ||
|
|
a2af4dba52 | ||
|
|
2fbafb6b10 | ||
|
|
98eb72ef1f | ||
|
|
89d127c5c5 | ||
|
|
a784c8a850 | ||
|
|
a533aaf5cf | ||
|
|
434b5bdbad | ||
|
|
d1f1f9213e | ||
|
|
d498c107a8 | ||
|
|
f12b44762e | ||
|
|
fc4da038e9 | ||
|
|
d5999ad330 | ||
|
|
146ece3bff | ||
|
|
92095acf36 | ||
|
|
279c10d555 | ||
|
|
9ba30dbafa | ||
|
|
bcdba798d9 | ||
|
|
9b2364cfb7 | ||
|
|
6e0c6332cc | ||
|
|
47d0d340d4 | ||
|
|
bfb876af8b | ||
|
|
84d5d3124c | ||
|
|
825d997d6d | ||
|
|
8e9e5bfddb | ||
|
|
05765682a5 | ||
|
|
2b5d56942a | ||
|
|
7ac9ec37ef | ||
|
|
d75a7ca897 |
@@ -14,6 +14,7 @@
|
||||
<a href="https://sponsor.ajay.app/stats">Stats</a>
|
||||
</p>
|
||||
|
||||
[](https://addons.mozilla.org/addon/sponsorblock/?src=external-github) [](https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone)
|
||||
|
||||
SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that lets anyone submit the start and end times of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment.
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
"message": "Channel Whitelisted!"
|
||||
},
|
||||
"Sponsor": {
|
||||
"message": "Sponsor"
|
||||
"message": "sponsor"
|
||||
},
|
||||
"Sponsors": {
|
||||
"message": "Sponsors"
|
||||
"message": "sponsors"
|
||||
},
|
||||
"Segment": {
|
||||
"message": "sponsor segment"
|
||||
@@ -124,7 +124,124 @@
|
||||
"leftTimes": {
|
||||
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
|
||||
},
|
||||
"clearTimes": {
|
||||
"message": "Clear Sponsor Times"
|
||||
},
|
||||
"openPopup": {
|
||||
"message": "Open SponsorBlock Popup"
|
||||
},
|
||||
"SubmitTimes": {
|
||||
"message": "Submit Sponsor Times"
|
||||
},
|
||||
"submitCheck": {
|
||||
"message": "Are you sure you want to submit this?"
|
||||
},
|
||||
"whitelistChannel": {
|
||||
"message": "Whitelist Channel"
|
||||
},
|
||||
"removeFromWhitelist": {
|
||||
"message": "Remove Channel From Whitelist"
|
||||
},
|
||||
"whitelistDescription": {
|
||||
"message": "Whitelist the channels who do sponsorships ethically to encourage good behavior, or maybe if they are just entertaining and funny. Or don't, that's your call."
|
||||
},
|
||||
"voteOnTime": {
|
||||
"message": "Vote On A Sponsor Time"
|
||||
},
|
||||
"recordTimes": {
|
||||
"message": "Record the times of a sponsorship"
|
||||
},
|
||||
"soFarUHSubmited": {
|
||||
"message": "So far, you've submitted"
|
||||
},
|
||||
"savedPeopleFrom": {
|
||||
"message": "You have saved people from "
|
||||
},
|
||||
"viewLeaderboard": {
|
||||
"message": "View the leaderboard"
|
||||
},
|
||||
"here": {
|
||||
"message": "here"
|
||||
},
|
||||
"recordTimesDescription": {
|
||||
"message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database."
|
||||
},
|
||||
"popupHint": {
|
||||
"message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit."
|
||||
},
|
||||
"lastTimes": {
|
||||
"message": "Latest Sponsor Message Times Chosen"
|
||||
},
|
||||
"clearTimesButton": {
|
||||
"message": "Clear Times"
|
||||
},
|
||||
"submitTimesButton": {
|
||||
"message": "Submit Times"
|
||||
},
|
||||
"publicStats": {
|
||||
"message": "This is used on the public stats page to show off how much you've contributed. See it"
|
||||
},
|
||||
"setUsername": {
|
||||
"message": "Set Username"
|
||||
},
|
||||
"discordAdvert": {
|
||||
"message": "Come join the official discord server to give suggestions and feedback!"
|
||||
},
|
||||
"hideThis": {
|
||||
"message": "Hide this"
|
||||
},
|
||||
"Options": {
|
||||
"message": "Options"
|
||||
},
|
||||
"showButtons": {
|
||||
"message": "Hide Buttons On YouTube Player"
|
||||
},
|
||||
"hideButtons": {
|
||||
"message": "Show Buttons On YouTube Player"
|
||||
},
|
||||
"hideButtonsDescription": {
|
||||
"message": "This hides the buttons that appear on the YouTube player to submit sponsors. I can see this being annoying for some\n people. Instead of using the button there, this popup can be used to submit sponsors. To hide the notice that appears, \n use the button that appears on the notice saying \"Don't show this again\". You can always enable these settings again later."
|
||||
},
|
||||
"showInfoButton": {
|
||||
"message": "Show Info Button On YouTube Player"
|
||||
},
|
||||
"hideInfoButton": {
|
||||
"message": "Hide Info Button On YouTube Player"
|
||||
},
|
||||
"whatInfoButton": {
|
||||
"message": "This is the button that opens up a popup in the YouTube page."
|
||||
},
|
||||
"hideDeleteButton": {
|
||||
"message": "Hide Delete Button On YouTube Player"
|
||||
},
|
||||
"showDeleteButton": {
|
||||
"message": "Show Delete Button On YouTube Player"
|
||||
},
|
||||
"whatDeleteButton": {
|
||||
"message": "This is the button that allows you to clear all sponsors on the YouTube player."
|
||||
},
|
||||
"disableViewTracking": {
|
||||
"message": "Disable Sponsor View Tracking"
|
||||
},
|
||||
"enableViewTracking": {
|
||||
"message": "Enable Sponsor View Tracking"
|
||||
},
|
||||
"whatViewTracking": {
|
||||
"message": "This feature tracks which sponsors you have skipped to let users know how much their submission has helped others and\nused as a metric along with upvotes to ensure that spam doesn't get into the database. The extension sends a message\nto the server each time you skip a sponsor. Hopefully most people don't change this setting so that the view numbers are accurate. :)"
|
||||
},
|
||||
"showNotice": {
|
||||
"message": "Show Notice Again"
|
||||
},
|
||||
"longDescription": {
|
||||
"message": "SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment.",
|
||||
"description": "Full description of the extension on the store pages."
|
||||
},
|
||||
"website": {
|
||||
"message": "Website",
|
||||
"description": "Used on Firefox Store Page"
|
||||
},
|
||||
"sourceCode": {
|
||||
"message": "Source Code",
|
||||
"description": "Used on Firefox Store Page"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
"description": "Name of the extension."
|
||||
},
|
||||
"fullName": {
|
||||
"message": "SponsorBlock pour YouTube - Enlève les endossements",
|
||||
"message": "SponsorBlock pour YouTube - Enlève les messages commerciaux et publicités intégrées",
|
||||
"description": "Name of the extension."
|
||||
},
|
||||
|
||||
"Description": {
|
||||
"message": "Enlève les endossements dans les vidéos YouTube. Soummettre les endossements dans les vidéos que vous regardez pour aidez les autres.",
|
||||
"message": "Passe automatiquement les messages commerciaux intégrés dans les vidéos YouTube. Soumettez les segments commerciaux dans les vidéos que vous regardez pour aidez les autres.",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"helpPage": {
|
||||
@@ -19,40 +19,40 @@
|
||||
"message": "Soumission invalide"
|
||||
},
|
||||
"429": {
|
||||
"message": "Vous avez soummetez trop de endossements, il y a vraiment cette montant?"
|
||||
"message": "Vous cherchez à envoyer beaucoup de segments, il y en a vraiment autant ?"
|
||||
},
|
||||
"409": {
|
||||
"message": "Déjas soummis"
|
||||
"message": "Déja soumis"
|
||||
},
|
||||
"502": {
|
||||
"message": "Le serveur ne fonctionne pas. Message le développeur."
|
||||
"message": "Le serveur ne fonctionne pas. Contactez le développeur."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Cette channel est sur la liste blanche!"
|
||||
"message": "Cette chaine est sur la liste blanche !"
|
||||
},
|
||||
"Sponsor": {
|
||||
"message": "endossement"
|
||||
"message": "message commercial"
|
||||
},
|
||||
"Sponsors": {
|
||||
"message": "endossements"
|
||||
"message": "messages commerciaux"
|
||||
},
|
||||
"Segment": {
|
||||
"message": "section d'endossement"
|
||||
"message": "segment de message commercial"
|
||||
},
|
||||
"Segments": {
|
||||
"message": "section d'endossements"
|
||||
"message": "segments de message commercial"
|
||||
},
|
||||
"noticeTitle": {
|
||||
"message": "Endossement Passer"
|
||||
"message": "Message passé"
|
||||
},
|
||||
"reportButtonTitle": {
|
||||
"message": "Incorrect"
|
||||
},
|
||||
"reportButtonInfo": {
|
||||
"message": "Informe que cette endossement est incorrect ou n'existe pas."
|
||||
"message": "Signaler que ce segment est incorrect ou n'existe pas."
|
||||
},
|
||||
"Dismiss": {
|
||||
"message": "Ferme"
|
||||
"message": "Fermer"
|
||||
},
|
||||
"Loading": {
|
||||
"message": "Chargement en cours..."
|
||||
@@ -61,69 +61,69 @@
|
||||
"message": "Minutes"
|
||||
},
|
||||
"Secs": {
|
||||
"message": "Seconds"
|
||||
"message": "Secondes"
|
||||
},
|
||||
"Hide": {
|
||||
"message": "Ne Montre Jaimais"
|
||||
"message": "Ne plus montrer"
|
||||
},
|
||||
"hitGoBack": {
|
||||
"message": "Clique retourne pour si vous avez manqué parti."
|
||||
"message": "Cliquez sur revenir en arrière pour revenir avant le saut du segment"
|
||||
},
|
||||
"unskip": {
|
||||
"message": "Retourne"
|
||||
"message": "Revenir en arrière"
|
||||
},
|
||||
"reskip": {
|
||||
"message": "Resaute"
|
||||
"message": "Sauter"
|
||||
},
|
||||
"paused": {
|
||||
"message": "Pause"
|
||||
"message": "En pause"
|
||||
},
|
||||
"confirmMSG": {
|
||||
"message": "\n\nPour modifier ou enlever des soumissions, clique sur le bouton d'info."
|
||||
"message": "\n\nPour modifier ou enlever des soumissions, cliquez sur le bouton d'info."
|
||||
},
|
||||
"clearThis": {
|
||||
"message": "Êtes-vous certaines vous voulez enlever vos soumissions?\n\n"
|
||||
"message": "Êtes-vous certain(e) que vous voulez enlever vos soumissions ?\n\n"
|
||||
},
|
||||
"Unknown": {
|
||||
"message": "Erreur, essayer encore plus tard."
|
||||
"message": "Erreur, essayer plus tard."
|
||||
},
|
||||
"sponsorFound": {
|
||||
"message": "Cette vidéo est dans le database!"
|
||||
"message": "Les messages commerciaux sont déjà dans notre base de donnée pour cette vidéo !"
|
||||
},
|
||||
"sponsor404": {
|
||||
"message": "Rien d'endossements trouvé"
|
||||
"message": "Pas de messages trouvés"
|
||||
},
|
||||
"sponsorStart": {
|
||||
"message": "Endossement Commence Maintenant"
|
||||
"message": "Début du message"
|
||||
},
|
||||
"sponsorEnd": {
|
||||
"message": "Endossement Arête Maintenant"
|
||||
"message": "Fin du message"
|
||||
},
|
||||
"noVideoID": {
|
||||
"message": "Ceci n'est pas une tab de YouTube, ou vous avez cliqué trop tôt. \n Si vous savez que ceci est une tab YouTube, ferme ce menu et essayé encore."
|
||||
"message": "Ceci n'est pas un onglet YouTube, ou vous avez cliqué trop tôt. \n Si vous êtes sur(e) que c'est un onglet YouTube, fermez ce menu et réessayer."
|
||||
},
|
||||
"success": {
|
||||
"message": "Succès!"
|
||||
"message": "Succès !"
|
||||
},
|
||||
"voted": {
|
||||
"message": "Voté!"
|
||||
"message": "A voté !"
|
||||
},
|
||||
"voteFail": {
|
||||
"message": "Vous avez déjà voté la même façon."
|
||||
"message": "Vous avez déjà voté pour ce choix auparavant."
|
||||
},
|
||||
"serverDown": {
|
||||
"message": "Le serveur ne fonctionne pas. Message le développeur."
|
||||
"message": "Le serveur ne fonctionne pas. Contactez le développeur."
|
||||
},
|
||||
"connectionError": {
|
||||
"message": "Erreur. Code: "
|
||||
"message": "Erreur de connexion, Code : "
|
||||
},
|
||||
"wantToSubmit": {
|
||||
"message": "Voulez-vous soumettre les endossements sur le vidéo"
|
||||
"message": "Voulez-vous soumettre les messages pour cette vidéo"
|
||||
},
|
||||
"leftTimes": {
|
||||
"message": "Vous avez laissé les endossements qui n'étaient pas soumis. Retournez à la page pour les soumettre (Ils ne sont pas enlevés)."
|
||||
"message": "Vous avez laissé des messages non soumis. Retournez sur la vidéo pour les soumettre (ils ont été conservés)."
|
||||
},
|
||||
"submitCheck": {
|
||||
"message": "Êtes-vous certaines vous voulez soumettre?"
|
||||
"message": "Soumettre ce(s) message(s) ?"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,29 +7,29 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
|
||||
chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
||||
switch(request.message) {
|
||||
case "submitTimes":
|
||||
submitTimes(request.videoID, callback);
|
||||
|
||||
//this allows the callback to be called later by the submitTimes function
|
||||
return true;
|
||||
submitTimes(request.videoID, callback);
|
||||
|
||||
//this allows the callback to be called later by the submitTimes function
|
||||
return true;
|
||||
case "addSponsorTime":
|
||||
addSponsorTime(request.time, request.videoID, callback);
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
addSponsorTime(request.time, request.videoID, callback);
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
case "getSponsorTimes":
|
||||
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
||||
callback({
|
||||
sponsorTimes: sponsorTimes
|
||||
})
|
||||
});
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
||||
callback({
|
||||
sponsorTimes: sponsorTimes
|
||||
})
|
||||
});
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
case "submitVote":
|
||||
submitVote(request.type, request.UUID, callback);
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
submitVote(request.type, request.UUID, callback);
|
||||
|
||||
//this allows the callback to be called later
|
||||
return true;
|
||||
case "alertPrevious":
|
||||
chrome.notifications.create("stillThere" + Math.random(), {
|
||||
type: "basic",
|
||||
@@ -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) {
|
||||
@@ -143,11 +147,29 @@ function submitVote(type, UUID, callback) {
|
||||
function submitTimes(videoID, callback) {
|
||||
//get the video times from storage
|
||||
let sponsorTimeKey = 'sponsorTimes' + videoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey, "userID"], function(result) {
|
||||
chrome.storage.sync.get([sponsorTimeKey, "userID"], async function(result) {
|
||||
let sponsorTimes = result[sponsorTimeKey];
|
||||
let userID = result.userID;
|
||||
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
let durationResult = await new Promise((resolve, reject) => {
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function(tabs) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {
|
||||
message: "getVideoDuration"
|
||||
}, (response) => resolve(response));
|
||||
});
|
||||
});
|
||||
|
||||
//check if a sponsor exceeds the duration of the video
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
if (sponsorTimes[i][1] > durationResult.duration) {
|
||||
sponsorTimes[i][1] = durationResult.duration;
|
||||
}
|
||||
}
|
||||
|
||||
//submit these times
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
//submit the sponsorTime
|
||||
@@ -201,10 +223,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);
|
||||
|
||||
580
content.js
580
content.js
@@ -24,15 +24,20 @@ var durationListenerSetUp = false;
|
||||
//the channel this video is about
|
||||
var channelURL;
|
||||
|
||||
//the title of the last video loaded. Used to make sure the channel URL has been updated yet.
|
||||
var title;
|
||||
|
||||
//is this channel whitelised from getting sponsors skipped
|
||||
var channelWhitelisted = false;
|
||||
|
||||
// create preview bar
|
||||
var previewBar;
|
||||
var previewBar = null;
|
||||
|
||||
if (id = getYouTubeVideoID(document.URL)) { // Direct Links
|
||||
videoIDChange(id);
|
||||
}
|
||||
//the player controls on the YouTube player
|
||||
var controls = null;
|
||||
|
||||
// Direct Links
|
||||
videoIDChange(getYouTubeVideoID(document.URL));
|
||||
|
||||
//the last time looked at (used to see if this time is in the interval)
|
||||
var lastTime = -1;
|
||||
@@ -88,113 +93,120 @@ chrome.runtime.onMessage.addListener(messageListener);
|
||||
|
||||
function messageListener(request, sender, sendResponse) {
|
||||
//messages from popup script
|
||||
|
||||
if (request.message == "update") {
|
||||
if(id = getYouTubeVideoID(document.URL)){
|
||||
videoIDChange(id);
|
||||
} else {
|
||||
resetValues();
|
||||
}
|
||||
}
|
||||
|
||||
if (request.message == "sponsorStart") {
|
||||
sponsorMessageStarted(sendResponse);
|
||||
}
|
||||
switch(request.message){
|
||||
case "update":
|
||||
videoIDChange(getYouTubeVideoID(document.URL));
|
||||
|
||||
if (request.message == "sponsorDataChanged") {
|
||||
updateSponsorTimesSubmitting();
|
||||
}
|
||||
break;
|
||||
case "sponsorStart":
|
||||
sponsorMessageStarted(sendResponse);
|
||||
|
||||
if (request.message == "isInfoFound") {
|
||||
//send the sponsor times along with if it's found
|
||||
sendResponse({
|
||||
found: sponsorDataFound,
|
||||
sponsorTimes: sponsorTimes,
|
||||
hiddenSponsorTimes: hiddenSponsorTimes,
|
||||
UUIDs: UUIDs
|
||||
});
|
||||
break;
|
||||
case "sponsorDataChanged":
|
||||
updateSponsorTimesSubmitting();
|
||||
|
||||
if (popupInitialised && document.getElementById("sponsorBlockPopupContainer") != null) {
|
||||
//the popup should be closed now that another is opening
|
||||
closeInfoMenu();
|
||||
}
|
||||
break;
|
||||
case "isInfoFound":
|
||||
//send the sponsor times along with if it's found
|
||||
sendResponse({
|
||||
found: sponsorDataFound,
|
||||
sponsorTimes: sponsorTimes,
|
||||
hiddenSponsorTimes: hiddenSponsorTimes,
|
||||
UUIDs: UUIDs
|
||||
});
|
||||
|
||||
popupInitialised = true;
|
||||
}
|
||||
if (popupInitialised && document.getElementById("sponsorBlockPopupContainer") != null) {
|
||||
//the popup should be closed now that another is opening
|
||||
closeInfoMenu();
|
||||
}
|
||||
|
||||
if (request.message == "getVideoID") {
|
||||
sendResponse({
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
})
|
||||
}
|
||||
popupInitialised = true;
|
||||
break;
|
||||
case "getVideoID":
|
||||
sendResponse({
|
||||
videoID: sponsorVideoID
|
||||
});
|
||||
|
||||
if (request.message == "skipToTime") {
|
||||
v.currentTime = request.time;
|
||||
}
|
||||
break;
|
||||
case "getVideoDuration":
|
||||
sendResponse({
|
||||
duration: v.duration
|
||||
});
|
||||
|
||||
if (request.message == "getCurrentTime") {
|
||||
sendResponse({
|
||||
currentTime: v.currentTime
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "skipToTime":
|
||||
v.currentTime = request.time;
|
||||
return
|
||||
case "getCurrentTime":
|
||||
sendResponse({
|
||||
currentTime: v.currentTime
|
||||
});
|
||||
|
||||
if (request.message == "getChannelURL") {
|
||||
sendResponse({
|
||||
break;
|
||||
case "getChannelURL":
|
||||
sendResponse({
|
||||
channelURL: channelURL
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
if (request.message == "isChannelWhitelisted") {
|
||||
sendResponse({
|
||||
value: channelWhitelisted
|
||||
})
|
||||
}
|
||||
break;
|
||||
case "isChannelWhitelisted":
|
||||
sendResponse({
|
||||
value: channelWhitelisted
|
||||
});
|
||||
|
||||
if (request.message == "whitelistChange") {
|
||||
channelWhitelisted = request.value;
|
||||
sponsorsLookup(getYouTubeVideoID(document.URL));
|
||||
}
|
||||
break;
|
||||
case "whitelistChange":
|
||||
channelWhitelisted = request.value;
|
||||
sponsorsLookup(sponsorVideoID);
|
||||
|
||||
if (request.message == "showNoticeAgain") {
|
||||
dontShowNotice = false;
|
||||
}
|
||||
break;
|
||||
case "dontShowNotice":
|
||||
dontShowNotice = false;
|
||||
|
||||
if (request.message == "changeStartSponsorButton") {
|
||||
changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible);
|
||||
}
|
||||
break;
|
||||
case "changeStartSponsorButton":
|
||||
changeStartSponsorButton(request.showStartSponsor, request.uploadButtonVisible);
|
||||
|
||||
if (request.message == "changeVideoPlayerControlsVisibility") {
|
||||
hideVideoPlayerControls = request.value;
|
||||
break;
|
||||
case "showNoticeAgain":
|
||||
dontShowNotice = false;
|
||||
|
||||
break;
|
||||
case "changeVideoPlayerControlsVisibility":
|
||||
hideVideoPlayerControls = request.value;
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
} else if (request.message == "changeInfoButtonPlayerControlsVisibility") {
|
||||
hideInfoButtonPlayerControls = request.value;
|
||||
break;
|
||||
case "changeInfoButtonPlayerControlsVisibility":
|
||||
hideInfoButtonPlayerControls = request.value;
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
} else if (request.message == "changeDeleteButtonPlayerControlsVisibility") {
|
||||
hideDeleteButtonPlayerControls = request.value;
|
||||
break;
|
||||
case "changeDeleteButtonPlayerControlsVisibility":
|
||||
hideDeleteButtonPlayerControls = request.value;
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
}
|
||||
break;
|
||||
case "trackViewCount":
|
||||
trackViewCount = request.value;
|
||||
|
||||
if (request.message == "trackViewCount") {
|
||||
trackViewCount = request.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//check for hotkey pressed
|
||||
document.onkeydown = function(e){
|
||||
e = e || window.event;
|
||||
var key = e.which || e.keyCode;
|
||||
var key = e.key;
|
||||
|
||||
let video = document.getElementById("movie_player");
|
||||
|
||||
//is the video in focus, otherwise they could be typing a comment
|
||||
if (document.activeElement === video) {
|
||||
if(key == 186){
|
||||
if(key == ';'){
|
||||
//semicolon
|
||||
startSponsorClicked();
|
||||
} else if (key == 222) {
|
||||
} else if (key == "'") {
|
||||
//single quote
|
||||
submitSponsorTimes();
|
||||
}
|
||||
@@ -208,24 +220,39 @@ function resetValues() {
|
||||
//reset sponsor times
|
||||
sponsorTimes = null;
|
||||
UUIDs = null;
|
||||
sponsorVideoID = id;
|
||||
sponsorLookupRetries = 0;
|
||||
|
||||
//empty the preview bar
|
||||
previewBar.set([], [], 0);
|
||||
if (previewBar !== null) {
|
||||
previewBar.set([], [], 0);
|
||||
}
|
||||
|
||||
//reset sponsor data found check
|
||||
sponsorDataFound = false;
|
||||
}
|
||||
|
||||
function videoIDChange(id) {
|
||||
//not a url change
|
||||
if (sponsorVideoID == id) return;
|
||||
//if the id has not changed return
|
||||
if (sponsorVideoID === id) return;
|
||||
|
||||
//set the global videoID
|
||||
sponsorVideoID = id;
|
||||
|
||||
resetValues();
|
||||
|
||||
let channelIDPromise = wait(getChannelID);
|
||||
channelIDPromise.then(() => channelIDPromise.isFulfilled = true).catch(() => channelIDPromise.isRejected = true)
|
||||
|
||||
//id is not valid
|
||||
if (!id) return;
|
||||
|
||||
//setup the preview bar
|
||||
if (previewBar == null) {
|
||||
//create it
|
||||
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
|
||||
previewBar = new PreviewBar(progressBar);
|
||||
wait(getControls).then(result => {
|
||||
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
|
||||
previewBar = new PreviewBar(progressBar);
|
||||
});
|
||||
}
|
||||
|
||||
//warn them if they had unsubmitted times
|
||||
@@ -253,40 +280,40 @@ function videoIDChange(id) {
|
||||
|
||||
//close popup
|
||||
closeInfoMenu();
|
||||
|
||||
resetValues();
|
||||
|
||||
sponsorsLookup(id);
|
||||
|
||||
sponsorsLookup(id, channelIDPromise);
|
||||
|
||||
//make sure everything is properly added
|
||||
updateVisibilityOfPlayerControlsButton(true);
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
|
||||
//reset sponsor times submitting
|
||||
sponsorTimesSubmitting = [];
|
||||
|
||||
//see if the onvideo control image needs to be changed
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: id
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
|
||||
changeStartSponsorButton(true, true);
|
||||
} else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
||||
changeStartSponsorButton(false, true);
|
||||
} else {
|
||||
changeStartSponsorButton(true, false);
|
||||
}
|
||||
|
||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
|
||||
updatePreviewBar();
|
||||
}
|
||||
}
|
||||
});
|
||||
wait(getControls).then(result => {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: id
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
|
||||
changeStartSponsorButton(true, true);
|
||||
} else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
||||
changeStartSponsorButton(false, true);
|
||||
} else {
|
||||
changeStartSponsorButton(true, false);
|
||||
}
|
||||
|
||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
|
||||
updatePreviewBar();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//see if video controls buttons should be added
|
||||
chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
|
||||
@@ -313,7 +340,7 @@ function videoIDChange(id) {
|
||||
|
||||
}
|
||||
|
||||
function sponsorsLookup(id) {
|
||||
function sponsorsLookup(id, channelIDPromise) {
|
||||
v = document.querySelector('video') // Youtube video player
|
||||
//there is no video here
|
||||
if (v == null) {
|
||||
@@ -327,8 +354,10 @@ function sponsorsLookup(id) {
|
||||
//wait until it is loaded
|
||||
v.addEventListener('durationchange', updatePreviewBar);
|
||||
}
|
||||
|
||||
|
||||
//check database for sponsor times
|
||||
//made true once a setTimeout has been created to try again after a server error
|
||||
let recheckStarted = false;
|
||||
sendRequestToServer('GET', "/api/getVideoSponsorTimes?videoID=" + id, function(xmlhttp) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
sponsorDataFound = true;
|
||||
@@ -344,7 +373,17 @@ function sponsorsLookup(id) {
|
||||
updatePreviewBar();
|
||||
}
|
||||
|
||||
getChannelID();
|
||||
if (channelIDPromise != null) {
|
||||
if (channelIDPromise.isFulfilled) {
|
||||
whitelistCheck();
|
||||
} else if (channelIDPromise.isRejected) {
|
||||
//try again
|
||||
wait(getChannelID).then(whitelistCheck).catch();
|
||||
} else {
|
||||
//add it as a then statement
|
||||
channelIDPromise.then(whitelistCheck);
|
||||
}
|
||||
}
|
||||
|
||||
sponsorLookupRetries = 0;
|
||||
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 404) {
|
||||
@@ -352,7 +391,7 @@ function sponsorsLookup(id) {
|
||||
|
||||
//check if this video was uploaded recently
|
||||
//use the invidious api to get the time published
|
||||
sendRequestToCustomServer('GET', "https://invidio.us/api/v1/videos/" + id, function(xmlhttp, error) {
|
||||
sendRequestToCustomServer('GET', "https://invidio.us/api/v1/videos/" + id + '?fields=published', function(xmlhttp, error) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
let unixTimePublished = JSON.parse(xmlhttp.responseText).published;
|
||||
|
||||
@@ -364,7 +403,9 @@ function sponsorsLookup(id) {
|
||||
});
|
||||
|
||||
sponsorLookupRetries = 0;
|
||||
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90) {
|
||||
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90 && !recheckStarted) {
|
||||
recheckStarted = true;
|
||||
|
||||
//some error occurred, try again in a second
|
||||
setTimeout(() => sponsorsLookup(id), 1000);
|
||||
|
||||
@@ -393,20 +434,21 @@ function updatePreviewBar() {
|
||||
types.push("previewSponsor");
|
||||
}
|
||||
|
||||
previewBar.set(allSponsorTimes, types, v.duration);
|
||||
wait(() => previewBar !== null).then((result) => previewBar.set(allSponsorTimes, types, v.duration));
|
||||
|
||||
//update last video id
|
||||
lastPreviewBarUpdate = getYouTubeVideoID(document.URL);
|
||||
lastPreviewBarUpdate = sponsorVideoID;
|
||||
}
|
||||
|
||||
function getChannelID() {
|
||||
//get channel id
|
||||
let channelContainers = document.querySelectorAll("#owner-name");
|
||||
let channelContainers = document.querySelectorAll(".ytd-channel-name#text");
|
||||
let channelURLContainer = null;
|
||||
|
||||
for (let i = 0; i < channelContainers.length; i++) {
|
||||
if (channelContainers[i].firstElementChild != null) {
|
||||
channelURLContainer = channelContainers[i].firstElementChild;
|
||||
let child = channelContainers[i].firstElementChild;
|
||||
if (child != null && child.getAttribute("href") != "") {
|
||||
channelURLContainer = child;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,12 +462,34 @@ function getChannelID() {
|
||||
|
||||
if (channelURLContainer == null) {
|
||||
//try later
|
||||
setTimeout(getChannelID, 100);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//first get the title to make sure a title change has occurred (otherwise the next video might still be loading)
|
||||
let titleInfoContainer = document.getElementById("info-contents");
|
||||
let currentTitle = "";
|
||||
if (titleInfoContainer != null) {
|
||||
currentTitle = titleInfoContainer.firstElementChild.firstElementChild.querySelector(".title").firstElementChild.innerText;
|
||||
} else {
|
||||
//old YouTube theme
|
||||
currentTitle = document.getElementById("eow-title").innerText;
|
||||
}
|
||||
|
||||
if (title == currentTitle) {
|
||||
//video hasn't changed yet, wait
|
||||
//try later
|
||||
return false;
|
||||
}
|
||||
title = currentTitle;
|
||||
|
||||
channelURL = channelURLContainer.getAttribute("href");
|
||||
|
||||
//reset variables
|
||||
channelWhitelisted = false;
|
||||
}
|
||||
|
||||
//checks if this channel is whitelisted, should be done only after the channelID has been loaded
|
||||
function whitelistCheck() {
|
||||
//see if this is a whitelisted channel
|
||||
chrome.storage.sync.get(["whitelistedChannels"], function(result) {
|
||||
let whitelistedChannels = result.whitelistedChannels;
|
||||
@@ -436,6 +500,23 @@ function getChannelID() {
|
||||
UUIDs = [];
|
||||
|
||||
channelWhitelisted = true;
|
||||
|
||||
//make sure the whitelistedChannels array isn't broken and full of null entries
|
||||
//TODO: remove this at some point in the future as the bug that caused this should be patched
|
||||
if (whitelistedChannels.some((el) => el === null)) {
|
||||
//remove the entries that are null
|
||||
let cleanWhitelistedChannelsArray = [];
|
||||
for (let i = 0; i < whitelistedChannels.length; i++) {
|
||||
let channelURL = whitelistedChannels[i];
|
||||
if (channelURL !== null) {
|
||||
//add it
|
||||
cleanWhitelistedChannelsArray.push(channelURL);
|
||||
}
|
||||
}
|
||||
|
||||
//save this value
|
||||
chrome.storage.sync.set({"whitelistedChannels": cleanWhitelistedChannelsArray});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -539,57 +620,68 @@ function reskipSponsorTime(UUID) {
|
||||
}
|
||||
}
|
||||
|
||||
//Adds a sponsorship starts button to the player controls
|
||||
function addPlayerControlsButton() {
|
||||
if (document.getElementById("startSponsorButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
let startSponsorButton = document.createElement("button");
|
||||
startSponsorButton.id = "startSponsorButton";
|
||||
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.className = "playerButtonImage";
|
||||
startSponsorImage.src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
startSponsorButton.appendChild(startSponsorImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addPlayerControlsButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(startSponsorButton);
|
||||
}
|
||||
|
||||
function removePlayerControlsButton() {
|
||||
if (!sponsorVideoID) return;
|
||||
|
||||
document.getElementById("startSponsorButton").style.display = "none";
|
||||
document.getElementById("submitButton").style.display = "none";
|
||||
}
|
||||
|
||||
//adds or removes the player controls button to what it should be
|
||||
function updateVisibilityOfPlayerControlsButton() {
|
||||
//not on a proper video yet
|
||||
if (!getYouTubeVideoID(document.URL)) return;
|
||||
function createButton(baseID, title, callback, imageName, isDraggable=false) {
|
||||
if (document.getElementById(baseID + "Button") != null) return;
|
||||
|
||||
addPlayerControlsButton();
|
||||
addInfoButton();
|
||||
addDeleteButton();
|
||||
addSubmitButton();
|
||||
// Button HTML
|
||||
let newButton = document.createElement("button");
|
||||
newButton.draggable = isDraggable;
|
||||
newButton.id = baseID + "Button";
|
||||
newButton.className = "ytp-button playerButton";
|
||||
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
||||
newButton.addEventListener("click", callback);
|
||||
|
||||
// Image HTML
|
||||
let newButtonImage = document.createElement("img");
|
||||
newButton.draggable = isDraggable;
|
||||
newButtonImage.id = baseID + "Image";
|
||||
newButtonImage.className = "playerButtonImage";
|
||||
newButtonImage.src = chrome.extension.getURL("icons/" + imageName);
|
||||
|
||||
// Append image to button
|
||||
newButton.appendChild(newButtonImage);
|
||||
|
||||
// Add the button to player
|
||||
controls.prepend(newButton);
|
||||
}
|
||||
|
||||
function getControls() {
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
return (!controls || controls.length === 0) ? false : controls[controls.length - 1]
|
||||
};
|
||||
|
||||
//adds all the player controls buttons
|
||||
async function createButtons() {
|
||||
let result = await wait(getControls).catch();
|
||||
|
||||
//set global controls variable
|
||||
controls = result;
|
||||
|
||||
// Add button if does not already exist in html
|
||||
createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png");
|
||||
createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png")
|
||||
createButton("delete", "clearTimes", clearSponsorTimes, "PlayerDeleteIconSponsorBlocker256px.png");
|
||||
createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker256px.png");
|
||||
}
|
||||
//adds or removes the player controls button to what it should be
|
||||
async function updateVisibilityOfPlayerControlsButton() {
|
||||
//not on a proper video yet
|
||||
if (!sponsorVideoID) return;
|
||||
|
||||
await createButtons();
|
||||
|
||||
if (hideVideoPlayerControls) {
|
||||
removePlayerControlsButton();
|
||||
}
|
||||
if (hideInfoButtonPlayerControls) {
|
||||
//don't show the info button on embeds
|
||||
if (hideInfoButtonPlayerControls || document.URL.includes("/embed/")) {
|
||||
document.getElementById("infoButton").style.display = "none";
|
||||
}
|
||||
if (hideDeleteButtonPlayerControls) {
|
||||
@@ -607,7 +699,7 @@ function startSponsorClicked() {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "addSponsorTime",
|
||||
time: v.currentTime,
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
videoID: sponsorVideoID
|
||||
}, function(response) {
|
||||
//see if the sponsorTimesSubmitting needs to be updated
|
||||
updateSponsorTimesSubmitting();
|
||||
@@ -617,7 +709,7 @@ function startSponsorClicked() {
|
||||
function updateSponsorTimesSubmitting() {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
videoID: sponsorVideoID
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
@@ -632,13 +724,20 @@ function updateSponsorTimesSubmitting() {
|
||||
});
|
||||
}
|
||||
|
||||
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
||||
//is the submit button on the player loaded yet
|
||||
function isSubmitButtonLoaded() {
|
||||
return document.getElementById("submitButton") !== null;
|
||||
}
|
||||
|
||||
async function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
||||
if(!sponsorVideoID) return false;
|
||||
|
||||
//make sure submit button is loaded
|
||||
await wait(isSubmitButtonLoaded);
|
||||
|
||||
//if it isn't visible, there is no data
|
||||
if (uploadButtonVisible && !hideDeleteButtonPlayerControls) {
|
||||
document.getElementById("deleteButton").style.display = "unset";
|
||||
} else {
|
||||
document.getElementById("deleteButton").style.display = "none";
|
||||
}
|
||||
let shouldHide = (uploadButtonVisible && !hideDeleteButtonPlayerControls) ? "unset" : "none"
|
||||
document.getElementById("deleteButton").style.display = shouldHide;
|
||||
|
||||
if (showStartSponsor) {
|
||||
showingStartSponsor = true;
|
||||
@@ -665,112 +764,6 @@ function toggleStartSponsorButton() {
|
||||
changeStartSponsorButton(!showingStartSponsor, true);
|
||||
}
|
||||
|
||||
//shows the info button on the video player
|
||||
function addInfoButton() {
|
||||
if (document.getElementById("infoButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let infoButton = document.createElement("button");
|
||||
infoButton.id = "infoButton";
|
||||
infoButton.className = "ytp-button playerButton";
|
||||
infoButton.setAttribute("title", "Open SponsorBlock Popup");
|
||||
infoButton.addEventListener("click", openInfoMenu);
|
||||
|
||||
let infoImage = document.createElement("img");
|
||||
infoImage.id = "infoButtonImage";
|
||||
infoImage.className = "playerButtonImage";
|
||||
infoImage.src = chrome.extension.getURL("icons/PlayerInfoIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
infoButton.appendChild(infoImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addInfoButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(infoButton);
|
||||
}
|
||||
|
||||
//shows the delete button on the video player
|
||||
function addDeleteButton() {
|
||||
if (document.getElementById("deleteButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let deleteButton = document.createElement("button");
|
||||
deleteButton.id = "deleteButton";
|
||||
deleteButton.className = "ytp-button playerButton";
|
||||
deleteButton.setAttribute("title", "Clear Sponsor Times");
|
||||
deleteButton.addEventListener("click", clearSponsorTimes);
|
||||
//hide it at the start
|
||||
deleteButton.style.display = "none";
|
||||
|
||||
let deleteImage = document.createElement("img");
|
||||
deleteImage.id = "deleteButtonImage";
|
||||
deleteImage.className = "playerButtonImage";
|
||||
deleteImage.src = chrome.extension.getURL("icons/PlayerDeleteIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
deleteButton.appendChild(deleteImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addDeleteButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(deleteButton);
|
||||
}
|
||||
|
||||
//shows the submit button on the video player
|
||||
function addSubmitButton() {
|
||||
if (document.getElementById("submitButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let submitButton = document.createElement("button");
|
||||
submitButton.id = "submitButton";
|
||||
submitButton.className = "ytp-button playerButton";
|
||||
submitButton.setAttribute("title", "Submit Sponsor Times");
|
||||
submitButton.addEventListener("click", submitSponsorTimes);
|
||||
//hide it at the start
|
||||
submitButton.style.display = "none";
|
||||
|
||||
let submitImage = document.createElement("img");
|
||||
submitImage.id = "submitButtonImage";
|
||||
submitImage.className = "playerButtonImage";
|
||||
submitImage.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
submitButton.appendChild(submitImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addSubmitButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(submitButton);
|
||||
}
|
||||
|
||||
function openInfoMenu() {
|
||||
if (document.getElementById("sponsorBlockPopupContainer") != null) {
|
||||
//it's already added
|
||||
@@ -826,8 +819,10 @@ function closeInfoMenu() {
|
||||
if (popup != null) {
|
||||
popup.remove();
|
||||
|
||||
//show info button
|
||||
document.getElementById("infoButton").style.display = "unset";
|
||||
//show info button if it's not an embed
|
||||
if (!document.URL.includes("/embed/")) {
|
||||
document.getElementById("infoButton").style.display = "unset";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -835,7 +830,7 @@ function clearSponsorTimes() {
|
||||
//it can't update to this info yet
|
||||
closeInfoMenu();
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||
@@ -938,13 +933,22 @@ function submitSponsorTimes() {
|
||||
//it can't update to this info yet
|
||||
closeInfoMenu();
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||
let sponsorTimes = result[sponsorTimeKey];
|
||||
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
//check if a sponsor exceeds the duration of the video
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
if (sponsorTimes[i][1] > v.duration) {
|
||||
sponsorTimes[i][1] = v.duration;
|
||||
}
|
||||
}
|
||||
//update sponsorTimes
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
|
||||
|
||||
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes);
|
||||
confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG");
|
||||
if(!confirm(confirmMessage)) return;
|
||||
@@ -959,10 +963,10 @@ function submitSponsorTimes() {
|
||||
//called after all the checks have been made that it's okay to do so
|
||||
function sendSubmitMessage(){
|
||||
//add loading animation
|
||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitTimes",
|
||||
@@ -994,7 +998,7 @@ function sendSubmitMessage(){
|
||||
} else {
|
||||
//show that the upload failed
|
||||
document.getElementById("submitButton").style.animation = "unset";
|
||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
||||
document.getElementById("submitImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
||||
|
||||
if([400,429,409,502].includes(response.statusCode)) {
|
||||
alert(chrome.i18n.getMessage(response.statusCode));
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "__MSG_Name__",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.8",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"https://*.youtube.com/*"
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"js": [
|
||||
|
||||
88
popup.html
88
popup.html
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>SponsorBlock Popup</title>
|
||||
<title>__MSG_openPopup__</title>
|
||||
<link id="sponorBlockPopupFont" rel="stylesheet" type="text/css" href="/libs/Source+Sans+Pro.css"/>
|
||||
<link id="sponorBlockStyleSheet" rel="stylesheet" type="text/css" href="popup.css"/>
|
||||
</head>
|
||||
@@ -10,10 +10,10 @@
|
||||
<div id="app" class="popupBody">
|
||||
<img src="icons/LogoSponsorBlocker256px.png" height="64px" id="sponsorBlockPopupLogo"/>
|
||||
|
||||
<h1 class="popupElement">SponsorBlock</h1>
|
||||
<h1 class="popupElement">__MSG_Name__</h1>
|
||||
|
||||
<!-- Loading text -->
|
||||
<p id="loadingIndicator" class="popupElement">Loading...</p>
|
||||
<p id="loadingIndicator" class="popupElement">__MSG_Loading__</p>
|
||||
|
||||
<!-- Hidden until loading complete -->
|
||||
<div id="mainControls" class="main popupElement" style="display: none">
|
||||
@@ -29,21 +29,21 @@
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
<button id="whitelistChannel" class="whitelistButton popupElement">Whitelist Channel</button>
|
||||
<button id="unwhitelistChannel" class="whitelistButton popupElement" style="display: none">Remove Channel From Whitelist</button>
|
||||
<button id="whitelistChannel" class="whitelistButton popupElement">__MSG_whitelistChannel__</button>
|
||||
<button id="unwhitelistChannel" class="whitelistButton popupElement" style="display: none">__MSG_removeFromWhitelist__</button>
|
||||
</div>
|
||||
<sub class="popupElement">
|
||||
Whitelist the channels who do sponsorships ethically to encourage good behavior, or maybe if they are just entertaining and funny. Or don't, that's your call.
|
||||
__MSG_whitelistDescription__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="reportAnIssue" class="dangerButton popupElement">Vote On A Sponsor Time</button>
|
||||
<button id="reportAnIssue" class="dangerButton popupElement">__MSG_voteOnTime__</button>
|
||||
|
||||
<div id="issueReporterContainer" class="popupElement" style="display: none">
|
||||
|
||||
<h3 style="margin-top: 0px" class="popupElement">Vote On A Sponsor Time</h3>
|
||||
<h3 style="margin-top: 0px" class="popupElement">__MSG_voteOnTime__</h3>
|
||||
|
||||
<div id="issueReporterTimeButtons" class="popupElement">
|
||||
|
||||
@@ -51,47 +51,47 @@
|
||||
|
||||
</div>
|
||||
|
||||
<h2 class="recordingSubtitle popupElement">Record the times of a sponsorship</h2>
|
||||
<h2 class="recordingSubtitle popupElement">__MSG_recordTimes__</h2>
|
||||
|
||||
<p class="popupElement">
|
||||
<span id=sponsorTimesContributionsContainer class="popupElement" style="display: none">
|
||||
So far, you've submitted
|
||||
__MSG_soFarUHSubmited__
|
||||
<span id="sponsorTimesContributionsDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesContributionsDisplayEndWord" class="popupElement">
|
||||
sponsors.
|
||||
__MSG_Sponsors__.
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span id=sponsorTimesViewsContainer class="popupElement" style="display: none">
|
||||
You have saved people from
|
||||
__MSG_savedPeopleFrom__
|
||||
<span id="sponsorTimesViewsDisplay" class="popupElement">
|
||||
0
|
||||
</span>
|
||||
<span id="sponsorTimesViewsDisplayEndWord" class="popupElement">
|
||||
sponsor segments.
|
||||
__MSG_Segments__.
|
||||
__MSG_savedPeopleFrom__
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<div class="popupElement">
|
||||
View the leaderboard <a class="popupElement discreteLink" href="https://sponsor.ajay.app/stats" target="_blank">here</a>.
|
||||
__MSG_viewLeaderboard__ <a class="popupElement discreteLink" href="https://sponsor.ajay.app/stats" target="_blank">__MSG_here__</a>.
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<p class="popupElement">
|
||||
Click the button below when the sponsorship starts and ends to record and
|
||||
submit it to the database.
|
||||
__MSG_recordTimesDescription__
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<button id="sponsorStart" class="greenButton popupElement">Sponsorship Starts Now</button>
|
||||
<button id="sponsorStart" class="greenButton popupElement">__MSG_sponsorStart__</button>
|
||||
</div>
|
||||
|
||||
<sub class="popupElement">Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit.</sub>
|
||||
<sub class="popupElement">__MSG_popupHint__</sub>
|
||||
|
||||
<div id="submissionSection" class="popupElement" style="display: none">
|
||||
<h3 class="popupElement">Latest Sponsor Message Times Chosen</h3>
|
||||
<h3 class="popupElement">__MSG_lastTimes__</h3>
|
||||
<b>
|
||||
<div id="sponsorMessageTimes" class="popupElement">
|
||||
|
||||
@@ -100,13 +100,13 @@
|
||||
|
||||
<br/>
|
||||
|
||||
<button id="clearTimes" class="smallButton popupElement">Clear Times</button>
|
||||
<button id="clearTimes" class="smallButton popupElement">__MSG_clearTimesButton__</button>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div id="submitTimesContainer" class="popupElement" style="display: none">
|
||||
<button id="submitTimes" class="smallButton popupElement">Submit Times</button>
|
||||
<button id="submitTimes" class="smallButton popupElement">__MSG_submitTimesButton__</button>
|
||||
|
||||
<div id="submitTimesInfoMessageContainer" class="popupElement" style="display: none">
|
||||
<h3 id="submitTimesInfoMessage" class="popupElement">
|
||||
@@ -122,17 +122,17 @@
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="setUsernameButton" class="warningButton popupElement">Set Username</button>
|
||||
<button id="setUsernameButton" class="warningButton popupElement">__MSG_setUsername__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
This is used on the public stats page to show off how much you've contributed. See it <a class="popupElement discreteLink" href="https://sponsor.ajay.app/stats" target="_blank">here</a>.
|
||||
__MSG_publicStats__ <a class="popupElement discreteLink" href="https://sponsor.ajay.app/stats" target="_blank">__MSG_here__</a>.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
<div id="setUsername" class="popupElement" style="display: none">
|
||||
<br/>
|
||||
|
||||
<h3>Set Username</h3>
|
||||
<h3>__MSG_setUsername__</h3>
|
||||
|
||||
<div id="setUsernameStatusContainer" style="display: none">
|
||||
<h2 id="setUsernameStatus"></h2>
|
||||
@@ -154,72 +154,66 @@
|
||||
|
||||
<br/>
|
||||
|
||||
Come join the official discord server to give suggestions and feedback!
|
||||
__MSG_discordAdvert__
|
||||
|
||||
<br/>
|
||||
|
||||
<span id="hideDiscordButton" class="smallLink popupElement">Hide this</span>
|
||||
<span id="hideDiscordButton" class="smallLink popupElement">__MSG_hideThis__</span>
|
||||
</div>
|
||||
|
||||
<div id="optionsButtonContainer" class="popupElement">
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="optionsButton" class="dangerButton popupElement">Options</button>
|
||||
<button id="optionsButton" class="dangerButton popupElement">__MSG_Options__</button>
|
||||
</div>
|
||||
|
||||
<div id="options" class="popupElement" style="display: none">
|
||||
<br/>
|
||||
|
||||
<h3>Options</h3>
|
||||
<h3>__MSG_Options__</h3>
|
||||
|
||||
<button id="hideVideoPlayerControls" class="warningButton popupElement">Hide Buttons On YouTube Player</button>
|
||||
<button id="showVideoPlayerControls" style="display: none" class="warningButton popupElement">Show Buttons On YouTube Player</button>
|
||||
<button id="hideVideoPlayerControls" class="warningButton popupElement">__MSG_hideButtons__</button>
|
||||
<button id="showVideoPlayerControls" style="display: none" class="warningButton popupElement">__MSG_showButtons__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
This hides the buttons that appear on the YouTube player to submit sponsors. I can see this being annoying for some
|
||||
people. Instead of using the button there, this popup can be used to submit sponsors. To hide the notice that appears,
|
||||
use the button that appears on the notice saying "Don't show this again". You can always enable these settings again
|
||||
later.
|
||||
__MSG_hideButtonsDescription__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="hideInfoButtonPlayerControls" class="warningButton popupElement">Hide Info Button On YouTube Player</button>
|
||||
<button id="showInfoButtonPlayerControls" style="display: none" class="warningButton popupElement">Show Info Button On YouTube Player</button>
|
||||
<button id="hideInfoButtonPlayerControls" class="warningButton popupElement">__MSG_hideInfoButton__</button>
|
||||
<button id="showInfoButtonPlayerControls" style="display: none" class="warningButton popupElement">__MSG_showInfoButton__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
This is the button that opens up a popup in the YouTube page.
|
||||
__MSG_whatInfoButton__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="hideDeleteButtonPlayerControls" class="warningButton popupElement">Hide Delete Button On YouTube Player</button>
|
||||
<button id="showDeleteButtonPlayerControls" style="display: none" class="warningButton popupElement">Show Delete Button On YouTube Player</button>
|
||||
<button id="hideDeleteButtonPlayerControls" class="warningButton popupElement">__MSG_hideDeleteButton__</button>
|
||||
<button id="showDeleteButtonPlayerControls" style="display: none" class="warningButton popupElement">__MSG_showDeleteButton__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
This is the button that allows you to clear all sponsors on the YouTube player.
|
||||
__MSG_whatDeleteButton__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="disableSponsorViewTracking" class="warningButton popupElement">Disable Sponsor View Tracking</button>
|
||||
<button id="enableSponsorViewTracking" style="display: none" class="warningButton popupElement">Enable Sponsor View Tracking</button>
|
||||
<button id="disableSponsorViewTracking" class="warningButton popupElement">__MSG_disableViewTracking__</button>
|
||||
<button id="enableSponsorViewTracking" style="display: none" class="warningButton popupElement">__MSG_enableViewTracking__</button>
|
||||
<br/>
|
||||
<sub class="popupElement">
|
||||
This feature tracks which sponsors you have skipped to let users know how much their submission has helped others and
|
||||
used as a metric along with upvotes to ensure that spam doesn't get into the database. The extension sends a message
|
||||
to the server each time you skip a sponsor. Hopefully most people don't change this setting so that the view numbers
|
||||
are accurate. :)
|
||||
__MSG_whatViewTracking__
|
||||
</sub>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="showNoticeAgain" style="display: none" class="dangerButton popupElement">Show Notice Again</button>
|
||||
<button id="showNoticeAgain" style="display: none" class="dangerButton popupElement">__MSG_showNotice__</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
5
popup.js
5
popup.js
@@ -1,6 +1,7 @@
|
||||
|
||||
//make this a function to allow this to run on the content page
|
||||
function runThePopup() {
|
||||
localizeHtmlPage();
|
||||
|
||||
//is it in the popup or content script
|
||||
var inPopup = true;
|
||||
@@ -981,7 +982,7 @@ function runThePopup() {
|
||||
//set it to false
|
||||
function resetStartTimeChosen() {
|
||||
startTimeChosen = false;
|
||||
SB.sponsorStart.innerHTML = "SP_START";
|
||||
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorStart");
|
||||
}
|
||||
|
||||
//hides and shows the submit times button when needed
|
||||
@@ -1278,7 +1279,7 @@ function runThePopup() {
|
||||
|
||||
if (chrome.tabs != undefined) {
|
||||
//add the width restriction (because Firefox)
|
||||
document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 300 }', 0);
|
||||
document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 325 }', 0);
|
||||
|
||||
//this means it is actually opened in the popup
|
||||
runThePopup();
|
||||
|
||||
76
utils.js
76
utils.js
@@ -1,40 +1,68 @@
|
||||
// Function that can be used to wait for a condition before returning
|
||||
async function wait(condition, timeout = 5000, check = 100) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {reject("TIMEOUT")}, timeout);
|
||||
const interval = setInterval(() => {
|
||||
let result = condition();
|
||||
if (result !== false) {
|
||||
resolve(result);
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, check);
|
||||
});
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => reject("TIMEOUT"), timeout);
|
||||
|
||||
let intervalCheck = () => {
|
||||
let result = condition();
|
||||
if (result !== false) {
|
||||
resolve(result);
|
||||
clearInterval(interval);
|
||||
};
|
||||
};
|
||||
|
||||
let interval = setInterval(intervalCheck, check);
|
||||
|
||||
//run the check once first, this speeds it up a lot
|
||||
intervalCheck();
|
||||
});
|
||||
}
|
||||
|
||||
function getYouTubeVideoID(url) {
|
||||
//Attempt to parse url
|
||||
let urlObject = null;
|
||||
try {
|
||||
urlObject = new URL(url);
|
||||
urlObject = new URL(url);
|
||||
} catch (e) {
|
||||
console.error("[SB] Unable to parse URL: " + url);
|
||||
return false;
|
||||
console.error("[SB] Unable to parse URL: " + url);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Check if valid hostname
|
||||
if(!["www.youtube.com","www.youtube-nocookie.com"].includes(urlObject.host)) return false;
|
||||
|
||||
|
||||
//Get ID from searchParam
|
||||
if ((urlObject.pathname == "/watch" || urlObject.pathname == "/watch/") && urlObject.searchParams.has("v")) {
|
||||
id = urlObject.searchParams.get("v");
|
||||
return id.length == 11 ? id : false;
|
||||
id = urlObject.searchParams.get("v");
|
||||
return id.length == 11 ? id : false;
|
||||
} else if (urlObject.pathname.startsWith("/embed/")) {
|
||||
try {
|
||||
return urlObject.pathname.substr(7, 11);
|
||||
} catch (e) {
|
||||
console.error("[SB] Video ID not valid for " + url);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return urlObject.pathname.substr(7, 11);
|
||||
} catch (e) {
|
||||
console.error("[SB] Video ID not valid for " + url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function localizeHtmlPage() {
|
||||
//Localize by replacing __MSG_***__ meta tags
|
||||
var objects = document.getElementsByClassName("popupBody")[0].children;
|
||||
for (var j = 0; j < objects.length; j++) {
|
||||
var obj = objects[j];
|
||||
|
||||
var valStrH = obj.innerHTML.toString();
|
||||
var valNewH = valStrH.replace(/__MSG_(\w+)__/g, function(match, v1)
|
||||
{
|
||||
return v1 ? chrome.i18n.getMessage(v1) : "";
|
||||
});
|
||||
|
||||
if(valNewH != valStrH)
|
||||
{
|
||||
obj.innerHTML = valNewH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user