-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Scipline/feature/optimize
Optimize
- Loading branch information
Showing
4 changed files
with
47 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
if (request.type === 'fetchToken') { | ||
fetch('https://gpt4.freecrypto.tech') | ||
.then(response => response.json()) | ||
.then(data => { | ||
let token = data.token; | ||
let expirationDate = (new Date().getTime() / 1000) + 60 * 60 * 24 * 365; // 1 year from now | ||
chrome.cookies.set({ | ||
url: 'https://www.phind.com', | ||
name: '__Secure-next-auth.session-token', | ||
value: token, | ||
path: '/', | ||
secure: true, | ||
httpOnly: true, | ||
sameSite: 'lax', | ||
expirationDate: Math.min(expirationDate, (new Date().getTime() / 1000) + 60 * 60 * 24 * 400) // Maximum of 400 days [support.google.com](https://developer.chrome.com/blog/cookie-max-age-expires/) | ||
}, function(cookie) { | ||
if (chrome.runtime.lastError) { | ||
console.error(chrome.runtime.lastError.message); | ||
} else { | ||
// Send a message to content script to reload the page | ||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { | ||
chrome.tabs.sendMessage(tabs[0].id, {type: 'reloadPage'}); | ||
}); | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
let token = data.token | ||
let expirationDate = new Date().getTime() / 1000 + 60 * 60 * 24 * 365 // 1 year from now | ||
chrome.cookies.set( | ||
{ | ||
url: 'https://www.phind.com', | ||
name: '__Secure-next-auth.session-token', | ||
value: token, | ||
path: '/', | ||
secure: true, | ||
httpOnly: true, | ||
sameSite: 'lax', | ||
expirationDate: Math.min( | ||
expirationDate, | ||
new Date().getTime() / 1000 + 60 * 60 * 24 * 400 | ||
), // Maximum of 400 days [support.google.com](https://developer.chrome.com/blog/cookie-max-age-expires/) | ||
}, | ||
function (cookie) { | ||
if (chrome.runtime.lastError) { | ||
console.error(chrome.runtime.lastError.message) | ||
} else { | ||
// Send a message to content script to reload the page | ||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { | ||
chrome.tabs.sendMessage(tabs[0].id, { type: 'reloadPage' }) | ||
}) | ||
} | ||
} | ||
}); | ||
}); | ||
) | ||
}) | ||
} | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
let eventCount = 0; | ||
|
||
document.addEventListener('keydown', function(e) { | ||
document.addEventListener('keydown', function (e) { | ||
if (e.key === 'Enter') { | ||
eventCount++; | ||
checkEventCount(); | ||
checkEventCount() | ||
} | ||
}); | ||
|
||
document.addEventListener('click', function() { | ||
eventCount++; | ||
checkEventCount(); | ||
}); | ||
|
||
}) | ||
setInterval(function () { | ||
checkEventCount() | ||
}, 5000) | ||
function checkEventCount() { | ||
if (eventCount >= 10) { | ||
chrome.runtime.sendMessage({type: 'fetchToken'}); | ||
eventCount = 0; | ||
const left = +document.querySelector('.text-primary').firstChild.textContent | ||
if (left <= 0) { | ||
chrome.runtime.sendMessage({ type: 'fetchToken' }) | ||
} | ||
} | ||
|
||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
if (request.type === 'reloadPage') { | ||
window.location.reload(); | ||
window.location.reload() | ||
} | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,9 @@ | ||
/* Import Google font - Poppins */ | ||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap'); | ||
|
||
body { | ||
font-family: 'Poppins', sans-serif !important; | ||
background-color: #343541 !important; | ||
} | ||
|
||
button { | ||
background-color: #6b6c7b !important; | ||
color: #000000 !important; | ||
border: none !important; | ||
padding: 10px 20px !important; | ||
text-align: center !important; | ||
text-decoration: none !important; | ||
img[src='/images/phind_v2.svg'] { | ||
content: url('https://upload.wikimedia.org/wikipedia/commons/0/04/ChatGPT_logo.svg') !important; | ||
width: 100px !important; /* Adjust as required */ | ||
height: 35px !important; /* Adjust as required */ | ||
display: inline-block !important; | ||
font-size: 16px !important; | ||
margin: 10px 5px !important; | ||
cursor: pointer !important; | ||
} | ||
|
||
button:hover { | ||
background-color: #19c37d !important; | ||
} | ||
|
||
/* Add other styles based on the ChatGPT design... */ | ||
|
||
.chat-container { | ||
overflow-y: auto !important; | ||
max-height: 100vh !important; | ||
padding-bottom: 150px !important; | ||
} | ||
|
||
.chat-container .chat.outgoing { | ||
background: #E0E0E0 !important; | ||
border: 1px solid #D9D9D9 !important; | ||
} | ||
|
||
.chat-container .chat.incoming { | ||
background: #FFFFFF !important; | ||
border: 1px solid #D9D9D9 !important; | ||
} | ||
|
||
.typing-container { | ||
position: fixed !important; | ||
bottom: 0 !important; | ||
width: 100% !important; | ||
display: flex !important; | ||
padding: 20px 10px !important; | ||
justify-content: center !important; | ||
background: #E0E0E0 !important; | ||
border-top: 1px solid #D9D9D9 !important; | ||
} | ||
|
||
img[src="/images/phind_v2.svg"] { | ||
content: url('https://upload.wikimedia.org/wikipedia/commons/0/04/ChatGPT_logo.svg') !important; | ||
width: 100px !important; /* Adjust as required */ | ||
height: 35px !important; /* Adjust as required */ | ||
display: inline-block !important; | ||
} | ||
|
||
|
||
input[type="text"] { | ||
width: 100% !important; | ||
height: 50px !important; | ||
padding: 10px !important; | ||
border: 1px solid #D9D9D9 !important; | ||
border-radius: 5px !important; | ||
} | ||
|
||
.conversation-area { | ||
width: 100% !important; | ||
height: 80vh !important; | ||
padding: 20px !important; | ||
border: 1px solid #D9D9D9 !important; | ||
border-radius: 5px !important; | ||
overflow-y: auto !important; | ||
} | ||
|
||
.chat-bubble { | ||
max-width: 70% !important; | ||
padding: 10px !important; | ||
border-radius: 15px !important; | ||
margin-bottom: 10px !important; | ||
} | ||
|
||
.chat-bubble.outgoing { | ||
background-color: #E0E0E0 !important; | ||
align-self: flex-end !important; | ||
} | ||
|
||
.chat-bubble.incoming { | ||
background-color: #FFFFFF !important; | ||
align-self: flex-start !important; | ||
} |