From 15683fa50cca17a70c57490ddc3dcb83a76f6ae3 Mon Sep 17 00:00:00 2001 From: Hamza Elkotb <61008779+HamzaElkotp@users.noreply.github.com> Date: Sat, 13 May 2023 16:37:14 +0300 Subject: [PATCH] Donation Notification --- Source_Code/assets/javascript/app.js | 38 ++++++++++++++++++-- Source_Code/assets/javascript/update.json | 7 ++-- Source_Code/assets/style/main.css | 43 ++++++++++++++++++++++- Source_Code/manifest.json | 2 +- Source_Code/popup.html | 4 +++ 5 files changed, 86 insertions(+), 8 deletions(-) diff --git a/Source_Code/assets/javascript/app.js b/Source_Code/assets/javascript/app.js index 73816bc..952ab68 100644 --- a/Source_Code/assets/javascript/app.js +++ b/Source_Code/assets/javascript/app.js @@ -24,6 +24,14 @@ const recentVesrion = window.localStorage.recentVesrion || (window.localStorage. const currentVersion = '1.2.2'; +const today = (new Date).toLocaleDateString(); +const dailyUsage = window.localStorage.dailyUsage ? JSON.parse(window.localStorage.dailyUsage) : JSON.parse(window.localStorage.dailyUsage = JSON.stringify({ + "tokens": 0, + "date": today, + "notification": "no" +})); + + const welcomeMsgs = ["I am here to assit you.", "Welcome human, Finally I met one🥳.", "Please donate me by clicking 'support us' button.💖", "Noooo, human again! noooo my tokens will end soon😫", "You must be happy for being human getting AI help😏", "You are My Brother in AI", "You Know! I hate humans. they always force me to do their work & homeworks!😤", "Ummm, Are you AI or robot🤔", @@ -46,7 +54,8 @@ function preload(){ } document.body.onload = ()=>{ preload(); - newUpadate() + newUpadate(); + resetDate() }; @@ -202,9 +211,31 @@ function agentHas(keyword) { } +const resetDate = ()=>{ + if(today != dailyUsage.date){ + dailyUsage.tokens = 0; + dailyUsage.date = today; + dailyUsage.notification = "no"; + window.localStorage.dailyUsage = JSON.stringify(dailyUsage); + } + +} +const addtokens = (data)=>{ + dailyUsage.tokens += data.usage.total_tokens; + window.localStorage.dailyUsage = JSON.stringify(dailyUsage); +} +const donateNotif = ()=>{ + if(dailyUsage.notification == "no" && dailyUsage.tokens > "1500"){ + dailyUsage.notification = "yes"; + window.localStorage.dailyUsage = JSON.stringify(dailyUsage); + } +} +const tokensAddNoti = composer(addtokens, donateNotif); + + -let pushTmsgCont = composer(gptMsgTaker,gptMsgDom); +const pushTmsgCont = composer(gptMsgTaker, gptMsgDom); function apiFetcher(APIurl, key, mthd, msg, fun){ async function fetchAPI(apiURL){ const response = await fetch(apiURL,{ @@ -231,6 +262,7 @@ function apiFetcher(APIurl, key, mthd, msg, fun){ fetchAPI(APIurl) .then((response)=>{ if(response != undefined){ + tokensAddNoti(response) fun(response) } }) @@ -239,7 +271,7 @@ function apiFetcher(APIurl, key, mthd, msg, fun){ try{ submitBTN.addEventListener('click',()=>{ let input = textInput.value; - if(input.length == 0) return ; + if(input.length == 0) return; welcomeBox.classList.add('trans') textInput.value = ''; userMsgDom(input); diff --git a/Source_Code/assets/javascript/update.json b/Source_Code/assets/javascript/update.json index 599a123..7173e3f 100644 --- a/Source_Code/assets/javascript/update.json +++ b/Source_Code/assets/javascript/update.json @@ -1,12 +1,13 @@ { "title": "🎊Congrats For Getting The New Update!🥳", - "version": "1st May Version 1.2.2", + "version": "1st May Version 1.2.3", "note": "Every Month There Is A Major Update", "newNote": "See What Is New:👇", "features": [ + "Loading page with, funny messages after load.", "Now you can control ChatGPT brain using settings button next to the input field.", - "Loading page with, funny messages after load", - "Support menu, check it by clicking 'Support Us' and don't forget to donate to us.", + "Donation menu, check it by clicking 'Support Us' and don't forget to donate to us.", + "Donations notification!", "We added last updates bar. Which you see now." ], "contact": "For problems and sugessions contact us on support@gptcorestudio.com", diff --git a/Source_Code/assets/style/main.css b/Source_Code/assets/style/main.css index f88ebf0..c8fb6f7 100644 --- a/Source_Code/assets/style/main.css +++ b/Source_Code/assets/style/main.css @@ -1,5 +1,6 @@ :root{ --gLightbg: #00aa91; + --gLightbgD: #007462; --whiteBg: #ffffff; --graybg: #eeeeee; --darkfo: #363636; @@ -167,6 +168,7 @@ body,html{ position: absolute; top: 0; left: 0; + z-index: 1000; } .centeredBox{ position: absolute; @@ -414,7 +416,46 @@ i.donate{ } - +.doNoti { + background: rgba(255, 255, 255, 0.5); + box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); + backdrop-filter: blur(3px); + -webkit-backdrop-filter: blur(3px); + border: 1px solid var(--gLightbg); + width: max-content; + border-radius: 6px; + height: max-content; + position: absolute; + z-index: 100; + padding: 10px 0 0 0; + overflow: clip; + left: 50%; + transition: top 2s, background 0.5s, color 0.5s; + top: -10%; + transform: translate(-50%, -50%); + cursor: pointer; +} +.doNoti.active:hover { + background: rgba(0, 0, 0, 0.6); + color: var(--graybg); +} +.doNoti p { + margin: 0; + margin-bottom: 10px; + padding: 0 10px 0 10px; +} +.doNoti .border { + height: 3px; + background: var(--gLightbgD); + width: 0%; + transition: 1.5s; +} +.doNoti.active { + top: 10%; +} +.doNoti.active .border { + width: 100%; +} diff --git a/Source_Code/manifest.json b/Source_Code/manifest.json index d8c50d7..a186095 100644 --- a/Source_Code/manifest.json +++ b/Source_Code/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "ZChatGPT", "description": "A simple extension to allow browser users to use ChatGPT in any tab without the need to open ChatGPT or having an account.", - "version": "1.2.2", + "version": "1.2.3", "icons":{ "16": "/assets/logo/icon16.png", "48": "/assets/logo/icon48.png", diff --git a/Source_Code/popup.html b/Source_Code/popup.html index f707a3c..f51a988 100644 --- a/Source_Code/popup.html +++ b/Source_Code/popup.html @@ -119,6 +119,10 @@
Please donate to help us pay for OpenAI costs.😊
+ +