mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
Made it warn you when you are on a non YouTube tab
This commit is contained in:
60
popup.html
60
popup.html
@@ -3,37 +3,41 @@
|
|||||||
<title>Set Page Color Popup</title>
|
<title>Set Page Color Popup</title>
|
||||||
<link rel="stylesheet" type="text/css" href="popup.css"/>
|
<link rel="stylesheet" type="text/css" href="popup.css"/>
|
||||||
</head>
|
</head>
|
||||||
<div id="app">
|
|
||||||
<div class="main">
|
<center>
|
||||||
<center>
|
<div id="app">
|
||||||
<h1>SponsorBlock</h1>
|
<h1>SponsorBlock</h1>
|
||||||
|
|
||||||
<!-- If the video was found in the database -->
|
<!-- Loading text -->
|
||||||
<div id="videoFound">
|
<p id="loadingIndicator">Loading...</p>
|
||||||
|
|
||||||
|
<!-- Hidden until loading complete -->
|
||||||
|
<div id="mainControls" class="main" style="display: none">
|
||||||
|
<!-- If the video was found in the database -->
|
||||||
|
<div id="videoFound">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button id="sponsorStart">Sponsorship Starts</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Latest Sponsor Message Times Chosen</h3>
|
||||||
|
<b>
|
||||||
|
<div id="sponsorMessageTimes">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</b>
|
||||||
|
|
||||||
|
<button id="clearTimes">Clear Times</button>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<button id="submitTimes">Submit Times</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<br/>
|
</center>
|
||||||
|
|
||||||
<div>
|
|
||||||
<button id="sponsorStart">Sponsorship Starts</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Latest Sponsor Message Times Chosen</h3>
|
|
||||||
<b>
|
|
||||||
<div id="sponsorMessageTimes">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</b>
|
|
||||||
|
|
||||||
<button id="clearTimes">Clear Times</button>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<button id="submitTimes">Submit Times</button>
|
|
||||||
</center>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</html>
|
</html>
|
||||||
19
popup.js
19
popup.js
@@ -11,6 +11,17 @@ var videoTimes = [];
|
|||||||
//current video ID of this tab
|
//current video ID of this tab
|
||||||
var currentVideoID = null;
|
var currentVideoID = null;
|
||||||
|
|
||||||
|
//is this a YouTube tab?
|
||||||
|
var isYouTubeTab = false;
|
||||||
|
|
||||||
|
//if no response comes by this point, give up
|
||||||
|
setTimeout(function() {
|
||||||
|
if (!isYouTubeTab) {
|
||||||
|
document.getElementById("loadingIndicator").innerHTML = "This probably isn't a YouTube tab, or you clicked too early." +
|
||||||
|
"If you know this is a YouTube tab, close this popup and open it again.";
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
chrome.tabs.query({
|
chrome.tabs.query({
|
||||||
active: true,
|
active: true,
|
||||||
currentWindow: true
|
currentWindow: true
|
||||||
@@ -46,6 +57,14 @@ function loadTabData(tabs) {
|
|||||||
function infoFound(request) {
|
function infoFound(request) {
|
||||||
//if request is undefined, then the page currently being browsed is not YouTube
|
//if request is undefined, then the page currently being browsed is not YouTube
|
||||||
if (request != undefined) {
|
if (request != undefined) {
|
||||||
|
//this must be a YouTube video
|
||||||
|
//set variable
|
||||||
|
isYouTubeTab = true;
|
||||||
|
|
||||||
|
//remove loading text
|
||||||
|
document.getElementById("mainControls").style.display = "unset"
|
||||||
|
document.getElementById("loadingIndicator").innerHTML = "";
|
||||||
|
|
||||||
if (request.found) {
|
if (request.found) {
|
||||||
document.getElementById("videoFound").innerHTML = "This video's sponsors are in the database!"
|
document.getElementById("videoFound").innerHTML = "This video's sponsors are in the database!"
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user