diff options
author | Ajay Ramachandran <[email protected]> | 2019-07-12 10:42:39 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2019-07-12 10:42:39 -0400 |
commit | c6cd092c8709f0a39645b806b8ba6508744ec640 (patch) | |
tree | e58f8cadc0dfa8b65695f8c8446f487738bd794b | |
parent | c31efc2059a7b2f483712259a356499dff7a1542 (diff) | |
download | SponsorBlock-c6cd092c8709f0a39645b806b8ba6508744ec640.tar.gz SponsorBlock-c6cd092c8709f0a39645b806b8ba6508744ec640.zip |
Added button on YouTube player and new icons to support that
-rw-r--r-- | content.js | 43 | ||||
-rw-r--r-- | icons/PlayerStartIconSponsorBlocker256px.png | bin | 0 -> 6225 bytes | |||
-rw-r--r-- | icons/PlayerStopIconSponsorBlocker256px.png | bin | 0 -> 7317 bytes | |||
-rw-r--r-- | manifest.json | 5 |
4 files changed, 38 insertions, 10 deletions
@@ -124,6 +124,31 @@ function goBackToPreviousTime() { } } +//Adds a sponsorship starts button to the player controls +function addPlayerControlsButton(){ + let startSponsorButton = document.createElement("button"); + startSponsorButton.className = "ytp-button"; + startSponsorButton.setAttribute("title", "Sponsor Starts Now"); + startSponsorButton.addEventListener("click", console.log); + + let startSponsorImage = document.createElement("img"); + startSponsorImage.style.height = "60%"; + startSponsorImage.style.top = "0"; + startSponsorImage.style.bottom = "0"; + startSponsorImage.style.display = "block"; + startSponsorImage.style.margin = "auto"; + startSponsorImage.src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); + + //add the image to the button + startSponsorButton.appendChild(startSponsorImage); + + let referenceNode = document.getElementsByClassName("ytp-right-controls")[0]; + + referenceNode.prepend(startSponsorButton); +} + +addPlayerControlsButton(); + //Opens the notice that tells the user that a sponsor was just skipped function openSkipNotice(){ if (dontShowNotice) { @@ -131,40 +156,40 @@ function openSkipNotice(){ return; } - var noticeElement = document.createElement("div"); + let noticeElement = document.createElement("div"); noticeElement.id = "sponsorSkipNotice"; noticeElement.className = "sponsorSkipObject"; - var logoElement = document.createElement("img"); + let logoElement = document.createElement("img"); logoElement.id = "sponsorSkipLogo"; logoElement.src = chrome.extension.getURL("icons/LogoSponsorBlocker256px.png"); - var noticeMessage = document.createElement("div"); + let noticeMessage = document.createElement("div"); noticeMessage.id = "sponsorSkipMessage"; noticeMessage.className = "sponsorSkipObject"; noticeMessage.innerText = "Hey, you just skipped a sponsor!"; - var noticeInfo = document.createElement("p"); + let noticeInfo = document.createElement("p"); noticeInfo.id = "sponsorSkipInfo"; noticeInfo.className = "sponsorSkipObject"; noticeInfo.innerText = "This message will disapear in 7 seconds"; - var buttonContainer = document.createElement("div"); + let buttonContainer = document.createElement("div"); buttonContainer.setAttribute("align", "center"); - var goBackButton = document.createElement("button"); + let goBackButton = document.createElement("button"); goBackButton.innerText = "Go back"; goBackButton.className = "sponsorSkipObject"; goBackButton.className = "sponsorSkipButton"; goBackButton.addEventListener("click", goBackToPreviousTime); - var hideButton = document.createElement("button"); + let hideButton = document.createElement("button"); hideButton.innerText = "Dismiss"; hideButton.className = "sponsorSkipObject"; hideButton.className = "sponsorSkipButton"; hideButton.addEventListener("click", closeSkipNotice); - var dontShowAgainButton = document.createElement("button"); + let dontShowAgainButton = document.createElement("button"); dontShowAgainButton.innerText = "Don't Show This Again"; dontShowAgainButton.className = "sponsorSkipObject"; dontShowAgainButton.className = "sponsorSkipDontShowButton"; @@ -181,7 +206,7 @@ function openSkipNotice(){ noticeElement.appendChild(noticeInfo); noticeElement.appendChild(buttonContainer); - var referenceNode = document.getElementById("info"); + let referenceNode = document.getElementById("info"); if (referenceNode == null) { //old YouTube referenceNode = document.getElementById("watch-header"); diff --git a/icons/PlayerStartIconSponsorBlocker256px.png b/icons/PlayerStartIconSponsorBlocker256px.png Binary files differnew file mode 100644 index 00000000..3adff0a4 --- /dev/null +++ b/icons/PlayerStartIconSponsorBlocker256px.png diff --git a/icons/PlayerStopIconSponsorBlocker256px.png b/icons/PlayerStopIconSponsorBlocker256px.png Binary files differnew file mode 100644 index 00000000..80ef4a6e --- /dev/null +++ b/icons/PlayerStopIconSponsorBlocker256px.png diff --git a/manifest.json b/manifest.json index 736cca75..9c7a7dd6 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,10 @@ } ], "web_accessible_resources": [ - "icons/LogoSponsorBlocker256px.png" + "icons/LogoSponsorBlocker256px.png", + "icons/IconSponsorBlocker256px.png", + "icons/PlayerStartIconSponsorBlocker256px.png", + "icons/PlayerStopIconSponsorBlocker256px.png" ], "permissions": [ "tabs", |