Skip to content

Commit

Permalink
Merge pull request #5 from ajayyy/experimental
Browse files Browse the repository at this point in the history
Added option to disable view count tracking
  • Loading branch information
ajayyy committed Jul 24, 2019
2 parents 55c7529 + 0f561d4 commit c7da0f0
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
19 changes: 18 additions & 1 deletion content.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ var showingStartSponsor = true;
//should the video controls buttons be added
var hideVideoPlayerControls = false;

//should view counts be tracked
var trackViewCount = false;
chrome.storage.sync.get(["trackViewCount"], function(result) {
let trackViewCountStorage = result.trackViewCount;
if (trackViewCountStorage != undefined) {
trackViewCount = trackViewCountStorage;
} else {
trackViewCount = true;
}
});

//if the notice should not be shown
//happens when the user click's the "Don't show notice again" button
var dontShowNotice = false;
Expand Down Expand Up @@ -86,6 +97,10 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes

updateVisibilityOfPlayerControlsButton();
}

if (request.message == "trackViewCount") {
trackViewCount = request.value;
}
});

function videoIDChange(id) {
Expand Down Expand Up @@ -177,7 +192,9 @@ function sponsorCheck(sponsorTimes) { // Video skipping
setTimeout(() => closeSkipNotice(currentUUID), 7000);

//send telemetry that a this sponsor was skipped happened
sendRequestToServer("GET", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
if (trackViewCount) {
sendRequestToServer("GET", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
}
}
}
lastTime = v.currentTime;
Expand Down
2 changes: 1 addition & 1 deletion firefox_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.1",
"version": "1.0.2",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [
{
Expand Down
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.1",
"version": "1.0.2",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [
{
Expand Down
22 changes: 21 additions & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,30 @@ <h3>Options</h3>

<button id="hideVideoPlayerControls" class="warningButton">Hide Button On YouTube Player</button>
<button id="showVideoPlayerControls" style="display: none" class="warningButton">Show Button On YouTube Player</button>
<br/>
<sub>
This hides the button that appears 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.
</sub>

<br/>
<br/>

<button id="disableSponsorViewTracking" class="warningButton">Disable Sponsor View Tracking</button>
<button id="enableSponsorViewTracking" style="display: none" class="warningButton">Enable Sponsor View Tracking</button>
<br/>
<sub>
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. :)
</sub>

<br/>
<br/>

<button id="showNoticeAgain" style="display: none" class="dangerButton">Show Notice Again</button>
</div>
</div>
Expand Down
45 changes: 45 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ document.getElementById("submitTimes").addEventListener("click", submitTimes);
document.getElementById("showNoticeAgain").addEventListener("click", showNoticeAgain);
document.getElementById("hideVideoPlayerControls").addEventListener("click", hideVideoPlayerControls);
document.getElementById("showVideoPlayerControls").addEventListener("click", showVideoPlayerControls);
document.getElementById("disableSponsorViewTracking").addEventListener("click", disableSponsorViewTracking);
document.getElementById("enableSponsorViewTracking").addEventListener("click", enableSponsorViewTracking);
document.getElementById("optionsButton").addEventListener("click", openOptions);
document.getElementById("reportAnIssue").addEventListener("click", reportAnIssue);

Expand Down Expand Up @@ -38,6 +40,15 @@ chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
}
});

//show proper tracking option
chrome.storage.sync.get(["trackViewCount"], function(result) {
let trackViewCount = result.trackViewCount;
if (trackViewCount != undefined && !trackViewCount) {
document.getElementById("disableSponsorViewTracking").style.display = "none";
document.getElementById("enableSponsorViewTracking").style.display = "unset";
}
});

//get the amount of times this user has contributed and display it to thank them
chrome.storage.sync.get(["sponsorTimesContributed"], function(result) {
if (result.sponsorTimesContributed != undefined) {
Expand Down Expand Up @@ -398,6 +409,40 @@ function showVideoPlayerControls() {
document.getElementById("showVideoPlayerControls").style.display = "none";
}

function disableSponsorViewTracking() {
chrome.storage.sync.set({"trackViewCount": false});

chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
message: "trackViewCount",
value: false
});
});

document.getElementById("disableSponsorViewTracking").style.display = "none";
document.getElementById("enableSponsorViewTracking").style.display = "unset";
}

function enableSponsorViewTracking() {
chrome.storage.sync.set({"trackViewCount": true});

chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
message: "trackViewCount",
value: true
});
});

document.getElementById("enableSponsorViewTracking").style.display = "none";
document.getElementById("disableSponsorViewTracking").style.display = "unset";
}

function updateStartTimeChosen() {
//update startTimeChosen variable
if (!startTimeChosen) {
Expand Down

0 comments on commit c7da0f0

Please sign in to comment.