Skip to content

Commit

Permalink
Merge pull request #44 from ajayyy/experimental
Browse files Browse the repository at this point in the history
Added discord link to popup
  • Loading branch information
ajayyy authored Jul 29, 2019
2 parents acb3c67 + 2415784 commit 6358ba2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SponsorBlock - YouTube Sponsorship Blocker",
"short_name": "SponsorBlock",
"version": "1.0.13",
"version": "1.0.14",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [
{
Expand Down
10 changes: 10 additions & 0 deletions popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ body {
filter: brightness(80%);
}

#discordButtonContainer {
font-size: 12px;
}

.smallLink {
font-size: 10px;
text-decoration: underline;
cursor: pointer;
}

.greenButton {
background-color:#ec1c1c;
-moz-border-radius:28px;
Expand Down
14 changes: 14 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ <h3 id="submitTimesInfoMessage">

</div>

<div id="discordButtonContainer" style="display: none">
<br/>

<a href="https://discord.gg/QnmVMpU" target="_blank"><img src="https://www.logolynx.com/images/logolynx/1b/1bcc0f0aefe71b2c8ce66ffe8645d365.png" height="32px"/></a>

<br/>

Come join the official discord server to give suggestions and feedback!

<br/>

<span id="hideDiscordButton" class="smallLink">Hide this</span>
</div>

<div id="optionsButtonContainer">
<br/>
<br/>
Expand Down
31 changes: 31 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ SB.sponsorTimesContributionsDisplayEndWord = document.getElementById("sponsorTim
SB.sponsorTimesViewsContainer = document.getElementById("sponsorTimesViewsDisplayContainer");
SB.sponsorTimesViewsDisplay = document.getElementById("sponsorTimesViewsDisplayDisplay");
SB.sponsorTimesViewsDisplayEndWord = document.getElementById("sponsorTimesViewsDisplayDisplayEndWord");
// discordButtons
SB.discordButtonContainer = document.getElementById("discordButtonContainer");
SB.hideDiscordButton = document.getElementById("hideDiscordButton");

//setup click listeners
SB.sponsorStart.addEventListener("click", sendSponsorStartMessage);
Expand All @@ -32,6 +35,8 @@ SB.disableSponsorViewTracking.addEventListener("click", disableSponsorViewTracki
SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking);
SB.optionsButton.addEventListener("click", openOptions);
SB.reportAnIssue.addEventListener("click", reportAnIssue);
SB.hideDiscordButton.addEventListener("click", hideDiscordButton);


//if true, the button now selects the end time
var startTimeChosen = false;
Expand All @@ -45,6 +50,26 @@ var currentVideoID = null;
//is this a YouTube tab?
var isYouTubeTab = false;

//see if discord link can be shown
chrome.storage.sync.get(["hideDiscordLink"], function(result) {
let hideDiscordLink = result.hideDiscordLink;
if (hideDiscordLink == undefined || !hideDiscordLink) {
chrome.storage.sync.get(["hideDiscordLaunches"], function(result) {
let hideDiscordLaunches = result.hideDiscordLaunches;
//only if less than 5 launches
if (hideDiscordLaunches == undefined || hideDiscordLaunches < 10) {
SB.discordButtonContainer.style.display = null;

if (hideDiscordLaunches == undefined) {
hideDiscordButton = 1;
}

chrome.storage.sync.set({"hideDiscordLaunches": hideDiscordButton + 1});
}
});
}
});

//if the don't show notice again variable is true, an option to
// disable should be available
chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
Expand Down Expand Up @@ -543,6 +568,12 @@ function vote(type, UUID) {
});
}

function hideDiscordButton() {
chrome.storage.sync.set({"hideDiscordLink": false});

SB.discordButtonContainer.style.display = "none";
}

//converts time in seconds to minutes:seconds
function getFormattedTime(seconds) {
let minutes = Math.floor(seconds / 60);
Expand Down

0 comments on commit 6358ba2

Please sign in to comment.