mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Added status if the video is in the database and fixed some errors.
This commit is contained in:
parent
2f32ead924
commit
fc8257e491
3 changed files with 38 additions and 5 deletions
|
@ -9,10 +9,16 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes
|
|||
SponsorsLookup(request.id);
|
||||
}
|
||||
|
||||
//message from popup script
|
||||
//messages from popup script
|
||||
if (request.message === 'sponsorStart') {
|
||||
sponsorMessageStarted();
|
||||
}
|
||||
|
||||
if (request.message === 'infoFound') {
|
||||
sendResponse({
|
||||
found: true
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
function SponsorsLookup(id) {
|
||||
|
|
|
@ -7,6 +7,14 @@
|
|||
<div class="main">
|
||||
<center>
|
||||
<h1>SponsorBlock</h1>
|
||||
|
||||
<!-- If the video was found in the database -->
|
||||
<div id="videoFound">
|
||||
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
<button id="sponsorStart">Sponsorship Starts</button>
|
||||
</div>
|
||||
|
|
27
popup.js
27
popup.js
|
@ -8,10 +8,10 @@ var startTimeChosen = false;
|
|||
var videoTimes = [];
|
||||
//load video times
|
||||
chrome.storage.local.get(['videoTimes'], function(result) {
|
||||
if (result.videoTimes != undefined) {
|
||||
if (result.videoTimes != undefined && result.videoTimes != []) {
|
||||
videoTimes = result.videoTimes;
|
||||
|
||||
if (videoTimes[videoTimes.length - 1].length < 2) {
|
||||
if (videoTimes[videoTimes.length - 1]!= undefined && videoTimes[videoTimes.length - 1].length < 2) {
|
||||
startTimeChosen = true;
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,35 @@ chrome.storage.local.get(['videoTimes'], function(result) {
|
|||
}
|
||||
});
|
||||
|
||||
//check if this video's sponsors are known
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, tabs => {
|
||||
chrome.tabs.sendMessage(
|
||||
tabs[0].id,
|
||||
{from: 'popup', message: 'infoFound'},
|
||||
infoFound
|
||||
);
|
||||
})
|
||||
|
||||
function infoFound(request) {
|
||||
if (request.found) {
|
||||
document.getElementById("videoFound").innerHTML = "This video's sponsors are in the database!"
|
||||
} else {
|
||||
document.getElementById("videoFound").innerHTML = "No sponsors found"
|
||||
}
|
||||
}
|
||||
|
||||
function sendSponsorStartMessage() {
|
||||
//the content script will get the message if a YouTube page is open
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, tabs => {
|
||||
// ...and send a request for the DOM info...
|
||||
chrome.tabs.sendMessage(
|
||||
tabs[0].id,
|
||||
{from: 'popup', subject: 'DOMInfo', message: 'sponsorStart'}
|
||||
{from: 'popup', message: 'sponsorStart'}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue