Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Donation Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaElkotp committed Jun 1, 2023
1 parent 656db75 commit 15683fa
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
38 changes: 35 additions & 3 deletions Source_Code/assets/javascript/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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🤔",
Expand All @@ -46,7 +54,8 @@ function preload(){
}
document.body.onload = ()=>{
preload();
newUpadate()
newUpadate();
resetDate()
};


Expand Down Expand Up @@ -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,{
Expand All @@ -231,6 +262,7 @@ function apiFetcher(APIurl, key, mthd, msg, fun){
fetchAPI(APIurl)
.then((response)=>{
if(response != undefined){
tokensAddNoti(response)
fun(response)
}
})
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions Source_Code/assets/javascript/update.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"title": "🎊Congrats For Getting The New Update!🥳",
"version": "<span class='is-size-6'>1st May</span> <span class='is-size-5'>Version</span> 1.2.2",
"version": "<span class='is-size-6'>1st May</span> <span class='is-size-5'>Version</span> 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 <span class='has-text-success'>[email protected]</span>",
Expand Down
43 changes: 42 additions & 1 deletion Source_Code/assets/style/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root{
--gLightbg: #00aa91;
--gLightbgD: #007462;
--whiteBg: #ffffff;
--graybg: #eeeeee;
--darkfo: #363636;
Expand Down Expand Up @@ -167,6 +168,7 @@ body,html{
position: absolute;
top: 0;
left: 0;
z-index: 1000;
}
.centeredBox{
position: absolute;
Expand Down Expand Up @@ -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%;
}



Expand Down
2 changes: 1 addition & 1 deletion Source_Code/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions Source_Code/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ <h1 class="heada">How your donation will help?</h1>
</div>
</div>

<div class="doNoti succ has-text-centered">
<p>Please donate to help us pay for OpenAI costs.😊</p>
<div class="border"></div>
</div>
</body>
</html>
<script src='/assets/javascript/app.js'></script>

0 comments on commit 15683fa

Please sign in to comment.