Skip to content

Commit

Permalink
Merge pull request #52 from ajayyy/experimental
Browse files Browse the repository at this point in the history
Firefox fixes
  • Loading branch information
ajayyy authored Jul 30, 2019
2 parents a1c8eca + a2b4f8d commit 7ed72fa
Show file tree
Hide file tree
Showing 7 changed files with 1,156 additions and 1,052 deletions.
9 changes: 9 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ var previousVideoID = null
//the id of this user, randomly generated once per install
var userID = null;

//the last video id loaded, to make sure it is a video id change
var sponsorVideoID = null;

//when a new tab is highlighted
chrome.tabs.onActivated.addListener(
function(activeInfo) {
Expand Down Expand Up @@ -162,6 +165,12 @@ function videoIDChange(currentVideoID, tabId) {
id: currentVideoID
});

//not a url change
if (sponsorVideoID == currentVideoID){
return;
}
sponsorVideoID = currentVideoID;

//warn them if they had unsubmitted times
if (previousVideoID != null) {
//get the sponsor times from storage
Expand Down
62 changes: 38 additions & 24 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
}
});

chrome.runtime.onMessage.addListener( // Detect URL Changes
function(request, sender, sendResponse) {
//get messages from the background script and the popup
chrome.runtime.onMessage.addListener(messageListener);

function messageListener(request, sender, sendResponse) {
//message from background script
if (request.message == "ytvideoid") {
videoIDChange(request.id);
Expand Down Expand Up @@ -118,7 +120,7 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes
if (request.message == "trackViewCount") {
trackViewCount = request.value;
}
});
}

//check for hotkey pressed
document.onkeydown = function(e){
Expand Down Expand Up @@ -474,31 +476,43 @@ function openInfoMenu() {
//hide info button
document.getElementById("infoButton").style.display = "none";

let popup = document.createElement("div");
popup.id = "sponsorBlockPopupContainer";

let popupFrame = document.createElement("iframe");
popupFrame.id = "sponsorBlockPopupFrame"
popupFrame.src = chrome.extension.getURL("popup.html");
popupFrame.className = "popup";
sendRequestToCustomServer('GET', chrome.extension.getURL("popup.html"), function(xmlhttp) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var popup = document.createElement("div");
popup.id = "sponsorBlockPopupContainer";
popup.innerHTML = xmlhttp.responseText

//close button
let closeButton = document.createElement("div");
closeButton.innerText = "Close Popup";
closeButton.classList = "smallLink";
closeButton.setAttribute("align", "center");
closeButton.addEventListener("click", closeInfoMenu);

//add the close button
popup.prepend(closeButton);

let parentNode = document.getElementById("secondary");
if (parentNode == null) {
//old youtube theme
parentNode = document.getElementById("watch7-sidebar-contents");
}

//close button
let closeButton = document.createElement("div");
closeButton.innerText = "Close Popup";
closeButton.classList = "smallLink";
closeButton.setAttribute("align", "center");
closeButton.addEventListener("click", closeInfoMenu);
//make the logo source not 404
//query selector must be used since getElementByID doesn't work on a node and this isn't added to the document yet
let logo = popup.querySelector("#sponsorBlockPopupLogo");
logo.src = chrome.extension.getURL("icons/LogoSponsorBlocker256px.png");

popup.appendChild(closeButton);
popup.appendChild(popupFrame);
//remove the style sheet and font that are not necessary
popup.querySelector("#sponorBlockPopupFont").remove();
popup.querySelector("#sponorBlockStyleSheet").remove();

let parentNode = document.getElementById("secondary");
if (parentNode == null) {
//old youtube theme
parentNode = document.getElementById("watch7-sidebar-contents");
}
parentNode.insertBefore(popup, parentNode.firstChild);

parentNode.prepend(popup);
//run the popup init script
runThePopup();
}
});
}

function closeInfoMenu() {
Expand Down
6 changes: 4 additions & 2 deletions firefox_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
],
"js": [
"config.js",
"content.js"
"content.js",
"popup.js"
],
"css": [
"content.css",
"./libs/Source+Sans+Pro.css"
"./libs/Source+Sans+Pro.css",
"popup.css"
]
}
],
Expand Down
8 changes: 5 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SponsorBlock for YouTube - Skip Sponsorships",
"short_name": "SponsorBlock",
"version": "1.0.16",
"version": "1.0.21",
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
"content_scripts": [
{
Expand All @@ -10,11 +10,13 @@
],
"js": [
"config.js",
"content.js"
"content.js",
"popup.js"
],
"css": [
"content.css",
"./libs/Source+Sans+Pro.css"
"./libs/Source+Sans+Pro.css",
"popup.css"
]
}
],
Expand Down
101 changes: 70 additions & 31 deletions popup.css
Original file line number Diff line number Diff line change
@@ -1,54 +1,93 @@
* {
/* reset some properties to default (youtube messes with them */
p.popupElement {
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}

h1.popupElement {
margin-block-start: 0.67em;
margin-block-end: 0.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
}

h2.popupElement {
margin-block-start: 0.83em;
margin-block-end: 0.83em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
}

h3.popupElement {
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
}

sub.popupElement {
font-size: smaller;
}
/* end reset */

.popupElement {
font-family: 'Source Sans Pro', sans-serif;

color: black;
}

h1 {
h1.popupElement {
margin-top: 0px;
}

body {
font-size: 14px;
min-width: 300px;
background-color: #ffd9d9;
.popupBody {
font-size: 14px;
background-color: #ffd9d9;
padding: 5px;
}

.recordingSubtitle {
.recordingSubtitle.popupElement {
margin-bottom: 10px;
}

.voteButton {
.voteButton.popupElement {
height: 32px;
margin-right: 15px;
cursor: pointer;
}
.voteButton:hover {
.voteButton:hover.popupElement {
filter: brightness(80%);
}

#discordButtonContainer {
#discordButtonContainer.popupElement {
font-size: 12px;
}

.sponsorTime {
.sponsorTime.popupElement {
font-size: 20px;
}

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

.mediumLink {
.mediumLink.popupElement {
font-size: 15px;
padding-left: 15px;
padding-right: 15px;
text-decoration: underline;
cursor: pointer;
}

.greenButton {
background-color:#ec1c1c;
.greenButton.popupElement {
background-color:#ec1c1c;
-moz-border-radius:28px;
-webkit-border-radius:28px;
border-radius:28px;
Expand All @@ -61,19 +100,19 @@ body {
text-decoration:none;
text-shadow:0px 0px 0px #662727;
}
.greenButton:hover {
.greenButton:hover.popupElement {
background-color:#bf2a2a;
}
.greenButton:focus {
.greenButton:focus.popupElement {
outline: none;
background-color:#bf2a2a;
}
.greenButton:active {
.greenButton:active.popupElement {
position:relative;
top:1px;
}

.dangerButton {
.dangerButton.popupElement {
-moz-box-shadow:inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow:inset 0px 1px 0px 0px #cf866c;
box-shadow:inset 0px 1px 0px 0px #cf866c;
Expand All @@ -90,19 +129,19 @@ body {
text-decoration:none;
text-shadow:0px 1px 0px #854629;
}
.dangerButton:hover {
.dangerButton:hover.popupElement {
background-color:#bc3315;
}
.dangerButton:focus {
.dangerButton:focus.popupElement {
outline: none;
background-color:#bc3315;
}
.dangerButton:active {
.dangerButton:active.popupElement {
position:relative;
top:1px;
}

.warningButton {
.warningButton.popupElement {
-moz-box-shadow:inset 0px 1px 0px 0px #cfbd6c;
-webkit-box-shadow:inset 0px 1px 0px 0px #cfbd6c;
box-shadow:inset 0px 1px 0px 0px #cfbd6c;
Expand All @@ -119,19 +158,19 @@ body {
text-decoration:none;
text-shadow:0px 1px 0px #856829;
}
.warningButton:hover {
.warningButton:hover.popupElement {
background-color:#bc8215;
}
.warningButton:focus {
.warningButton:focus.popupElement {
outline: none;
background-color:#bc8215;
}
.warningButton:active {
.warningButton:active.popupElement {
position:relative;
top:1px;
}

.smallButton {
.smallButton.popupElement {
background-color:#f9902d;
-moz-border-radius:3px;
-webkit-border-radius:3px;
Expand All @@ -144,14 +183,14 @@ body {
padding:6px 10px;
text-decoration:none;
}
.smallButton:hover {
.smallButton:hover.popupElement {
background-color:#fa9806;
}
.smallButton:focus {
.smallButton:focus.popupElement {
outline: none;
background-color:#fa9806;
}
.smallButton:active {
.smallButton:active.popupElement {
position:relative;
top:1px;
}
}
Loading

0 comments on commit 7ed72fa

Please sign in to comment.