Skip to content

Commit 5fc23aa

Browse files
committed
Tweak donation button
1 parent 23129a5 commit 5fc23aa

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

donation.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,25 @@ var MapSwitcherDonation = null;
1414

1515
{
1616
const lastDonationClick = localStorage.stravaMapSwitcherLastDonationClick;
17-
if (!lastDonationClick || (Date.now() - lastDonationClick) > 1000 * 86400 * 180) {
18-
MapSwitcherDonation = jQuery('<a href="https://www.paypal.me/lisknisi/10EUR" target="_blank">♥=€ strava-map-switcher</a>');
19-
MapSwitcherDonation.click(function () {
20-
localStorage.stravaMapSwitcherLastDonationClick = Date.now();
21-
});
17+
const clickedRecently = lastDonationClick && (Date.now() - lastDonationClick) < 1000 * 86400 * 180;
18+
19+
const lastDonationVersion = localStorage.stravaMapSwitcherLastDonationVersion;
20+
const thisVersion = localStorage.stravaMapSwitcherVersion;
21+
const clickedThisVersion = !thisVersion || (lastDonationVersion && thisVersion == lastDonationVersion);
22+
23+
if (!clickedRecently || !clickedThisVersion) {
24+
MapSwitcherDonation =
25+
jQuery('<a href="https://www.paypal.me/lisknisi/10EUR" target="_blank">')
26+
.text('♥=€ strava-map-switcher')
27+
.css({'font-weight': 'bold'})
28+
.click(function () {
29+
localStorage.stravaMapSwitcherLastDonationClick = Date.now();
30+
localStorage.stravaMapSwitcherLastDonationVersion = thisVersion;
31+
});
32+
} else {
33+
MapSwitcherDonation =
34+
jQuery('<a href="https://github.com/liskin/strava-map-switcher#readme" target="_blank">')
35+
.text('strava-map-switcher')
36+
.css({'font-weight': 'bold'});
2237
}
2338
}

inject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212

1313
{
14+
localStorage.stravaMapSwitcherVersion = chrome.runtime.getManifest().version;
15+
1416
const s = document.createElement("script");
1517
s.src = chrome.runtime.getURL("load.js");
1618
s.type = 'text/javascript';

0 commit comments

Comments
 (0)