mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Add popup donation prompt
This commit is contained in:
parent
c66e624c16
commit
fce82b48b0
8 changed files with 88 additions and 4 deletions
|
@ -47,6 +47,7 @@
|
|||
"icons/beep.ogg",
|
||||
"icons/pause.svg",
|
||||
"icons/stop.svg",
|
||||
"icons/heart.svg",
|
||||
"icons/PlayerInfoIconSponsorBlocker.svg",
|
||||
"icons/PlayerDeleteIconSponsorBlocker.svg",
|
||||
"popup.html",
|
||||
|
|
|
@ -787,6 +787,9 @@
|
|||
"Donate": {
|
||||
"message": "Donate"
|
||||
},
|
||||
"considerDonating": {
|
||||
"message": "Help fund development"
|
||||
},
|
||||
"hideDonationLink": {
|
||||
"message": "Hide Donation Link"
|
||||
},
|
||||
|
|
43
public/icons/heart.svg
Normal file
43
public/icons/heart.svg
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
width="24px"
|
||||
fill="#000000"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="heart.svg"
|
||||
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
id="namedview8"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
showgrid="false"
|
||||
inkscape:zoom="32.916667"
|
||||
inkscape:cx="11.98481"
|
||||
inkscape:cy="12.01519"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="731"
|
||||
inkscape:window-x="1366"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M0 0h24v24H0V0z"
|
||||
fill="none"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"
|
||||
id="path4"
|
||||
style="fill:#800000" />
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -393,7 +393,7 @@ label>p, #disableExtension>p, #usernameValue, #usernameElement > div > p,#sponso
|
|||
|
||||
/* footer */
|
||||
|
||||
#sbFooter > a {
|
||||
#sbFooter a {
|
||||
color: var(--sb-main-fg-color);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -138,6 +138,14 @@
|
|||
<span id="sponsorTimeSavedEndWord">__MSG_minsLower__</span></b>).
|
||||
</div>
|
||||
<footer id="sbFooter">
|
||||
<div id="sponsorTimesDonateContainer" style="display: none; align-items: center;">
|
||||
<img src="/icons/heart.svg"/>
|
||||
<a id="sbConsiderDonateLink" href="https://sponsor.ajay.app/donate" target="_blank" rel="noopener">
|
||||
__MSG_considerDonating__
|
||||
</a>
|
||||
<img id="sbCloseDonate" src="/icons/close.png" height="8px" style="padding-left: 5px; cursor: pointer;"/>
|
||||
</div>
|
||||
|
||||
<a href="https://sponsor.ajay.app" target="_blank" rel="noopener">__MSG_website__</a> |
|
||||
<a href="https://sponsor.ajay.app/stats" target="_blank" rel="noopener">__MSG_viewLeaderboard__</a> |
|
||||
<a href="https://github.com/ajayyy/SponsorBlock" target="_blank" rel="noopener">GitHub</a>
|
||||
|
|
|
@ -43,6 +43,8 @@ interface SBConfig {
|
|||
ytInfoPermissionGranted: boolean,
|
||||
allowExpirements: boolean,
|
||||
showDonationLink: boolean,
|
||||
showPopupDonationCount: number,
|
||||
donateClicked: number,
|
||||
autoHideInfoButton: boolean,
|
||||
autoSkipOnMusicVideos: boolean,
|
||||
colorPalette: {
|
||||
|
@ -146,6 +148,8 @@ const Config: SBObject = {
|
|||
ytInfoPermissionGranted: false,
|
||||
allowExpirements: true,
|
||||
showDonationLink: true,
|
||||
showPopupDonationCount: 0,
|
||||
donateClicked: 0,
|
||||
autoHideInfoButton: true,
|
||||
autoSkipOnMusicVideos: false,
|
||||
scrollToEditTimeUpdate: false, // false means the tooltip will be shown
|
||||
|
|
|
@ -54,8 +54,10 @@ async function init() {
|
|||
document.documentElement.setAttribute("data-theme", "light");
|
||||
}
|
||||
|
||||
const donate = document.getElementById("sbDonate");
|
||||
donate.addEventListener("click", () => Config.config.donateClicked = Config.config.donateClicked + 1);
|
||||
if (!showDonationLink()) {
|
||||
document.getElementById("sbDonate").classList.add("hidden");
|
||||
donate.classList.add("hidden");
|
||||
}
|
||||
|
||||
// Set all of the toggle options to the correct option
|
||||
|
@ -501,7 +503,7 @@ function activatePrivateTextChange(element: HTMLElement) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
textBox.value = result;
|
||||
|
||||
const setButton = element.querySelector(".text-change-set");
|
||||
|
|
25
src/popup.ts
25
src/popup.ts
|
@ -108,13 +108,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||
//"downloadedSponsorMessageTimes",
|
||||
"refreshSegmentsButton",
|
||||
"whitelistButton",
|
||||
"sbDonate"
|
||||
"sbDonate",
|
||||
"sponsorTimesDonateContainer",
|
||||
"sbConsiderDonateLink",
|
||||
"sbCloseDonate"
|
||||
].forEach(id => PageElements[id] = document.getElementById(id));
|
||||
|
||||
// Hide donate button if wanted (Safari, or user choice)
|
||||
if (!showDonationLink()) {
|
||||
PageElements.sbDonate.style.display = "none";
|
||||
}
|
||||
PageElements.sbDonate.addEventListener("click", () => Config.config.donateClicked = Config.config.donateClicked + 1);
|
||||
|
||||
//setup click listeners
|
||||
PageElements.sponsorStart.addEventListener("click", sendSponsorStartMessage);
|
||||
|
@ -192,6 +196,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||
PageElements.sponsorTimesViewsDisplay.innerText = viewCount.toLocaleString();
|
||||
PageElements.sponsorTimesViewsContainer.style.display = "unset";
|
||||
}
|
||||
|
||||
showDonateWidget(viewCount);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -241,6 +247,23 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||
|
||||
getSegmentsFromContentScript(false);
|
||||
|
||||
function showDonateWidget(viewCount: number) {
|
||||
if (Config.config.showDonationLink && Config.config.donateClicked <= 0 && Config.config.showPopupDonationCount < 5
|
||||
&& viewCount < 50000 && !Config.config.isVip && Config.config.skipCount > 10) {
|
||||
PageElements.sponsorTimesDonateContainer.style.display = "flex";
|
||||
PageElements.sbConsiderDonateLink.addEventListener("click", () => {
|
||||
Config.config.donateClicked = Config.config.donateClicked + 1;
|
||||
});
|
||||
|
||||
PageElements.sbCloseDonate.addEventListener("click", () => {
|
||||
PageElements.sponsorTimesDonateContainer.style.display = "none";
|
||||
Config.config.showPopupDonationCount = 100;
|
||||
});
|
||||
|
||||
Config.config.showPopupDonationCount = Config.config.showPopupDonationCount + 1;
|
||||
}
|
||||
}
|
||||
|
||||
function onTabs(tabs, updating: boolean): void {
|
||||
messageHandler.sendMessage(tabs[0].id, { message: 'getVideoID' }, function (result) {
|
||||
if (result !== undefined && result.videoID) {
|
||||
|
|
Loading…
Reference in a new issue