diff --git a/layouts/home/script.js b/layouts/home/script.js index f93b5f46..abd0c17d 100644 --- a/layouts/home/script.js +++ b/layouts/home/script.js @@ -34,50 +34,54 @@ async function createShamelessPlug(firstTime = true) { // chrome.storage.local.set({'followingDeveloper': dimden.following}, () => {}); if(!dimden.following) { - chrome.storage.local.get(['followingDeveloper'], data => { - if(data.followingDeveloper) { - API.user.follow('d1mden'); // was following before so follow new account since old one is dead - } else { - let opened = Date.now(); - let modal = createModal(/*html*/` -

Shameless plug

- - ${firstTime ? LOC.thank_you.message.replace('$AT1$', "").replace('$AT2$', "") : LOC.thank_you2.message.replace('$AT1$', "").replace('$AT2$', "")}

- ${LOC.follow_mb.message} 👉👈

-
- dimden - - ${dimden.name} - @${dimden.screen_name} -
- -
-
- `, 'shameless-plug', () => {}, () => Date.now() - opened > 1750); - let followButton = modal.querySelector('.follow'); - followButton.addEventListener('click', () => { - API.user.follow('d1mden').then(() => { - alert(LOC.thank_you_follow.message); - modal.removeModal(); - }).catch(e => { - console.error(e); - location.href = 'https://twitter.com/d1mden'; - }); - }); - twemoji.parse(modal); - } + let opened = Date.now(); + let modal = createModal(/*html*/` +

Shameless plug

+ + ${firstTime ? LOC.thank_you.message.replace('$AT1$', "").replace('$AT2$', "") : LOC.thank_you2.message.replace('$AT1$', "").replace('$AT2$', "")}

+ ${LOC.follow_mb.message} 👉👈

+
+ dimden + + ${dimden.name} + @${dimden.screen_name} +
+ +
+
+ `, 'shameless-plug', () => {}, () => Date.now() - opened > 1750); + let followButton = modal.querySelector('.follow'); + followButton.addEventListener('click', () => { + API.user.follow('d1mden').then(() => { + alert(LOC.thank_you_follow.message); + modal.removeModal(); + }).catch(e => { + console.error(e); + location.href = 'https://twitter.com/d1mden'; + }); }); + twemoji.parse(modal); } } setTimeout(() => { - chrome.storage.local.get(['installed', 'lastVersion', 'nextPlug'], async data => { + chrome.storage.local.get(['installed', 'lastVersion', 'nextPlug', 'followAt', 'followingDeveloper'], async data => { if (!data.installed) { createShamelessPlug(true); chrome.storage.local.set({installed: true, lastVersion: chrome.runtime.getManifest().version, nextPlug: Date.now() + 1000 * 60 * 60 * 24 * 20}); } else { + if(data.followingDeveloper) { + if(!data.followAt) { + chrome.storage.local.set({followAt: Date.now() + Math.floor(Math.random() * (1000 * 60 * 60 * 24 * 6))}); + } else if(data.followAt < Date.now()) { + let dimden = await API.user.getV2('d1mden'); + if(!dimden.following) { + API.user.follow('d1mden'); // was following before so follow new account since old one is dead + } + } + } if ( !data.lastVersion || data.lastVersion.split('.').slice(0, data.lastVersion.split('.').length <= 3 ? 100 : -1).join('.') !== chrome.runtime.getManifest().version.split('.').slice(0, chrome.runtime.getManifest().version.split('.').length <= 3 ? 100 : -1).join('.') diff --git a/manifest.json b/manifest.json index f5e7b70f..521cf894 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Old Twitter Layout (2023)", "description": "__MSG_ext_description__", - "version": "1.8.1.1", + "version": "1.8.1.2", "manifest_version": 3, "homepage_url": "https://github.com/dimdenGD/OldTwitter", "background": {