-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dependabot/npm_and_yarn/apps/dfda-1/publi…
…c/app/es5-ext-0.10.64
- Loading branch information
Showing
152 changed files
with
15,629 additions
and
1,437 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,2 +1,9 @@ | ||
# Get this from https://platform.openai.com/account/api-keys | ||
OPENAI_API_KEY=YOUR_API_KEY | ||
OPENAI_MODEL=gpt-3.5-turbo-0125 | ||
|
||
# Get this from https://lightsail.aws.amazon.com/ls/webapp/us-east-1/buckets | ||
AWS_ACCESS_KEY_ID=your_access_key_id | ||
AWS_SECRET_ACCESS_KEY=your_secret_access_key | ||
AWS_REGION=your_aws_region | ||
BUCKET_NAME=your_s3_bucket_name |
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 |
---|---|---|
|
@@ -57,3 +57,4 @@ litellm_uuid.txt | |
.smart-connections | ||
.space | ||
.makemd | ||
desktop.ini |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Function to extract the data | ||
function extractAndSaveAmazon() { | ||
// Send a message to the background script to navigate to the Amazon order history page | ||
chrome.runtime.sendMessage({action: "navigate", url: "https://www.amazon.com/gp/css/order-history"}); | ||
|
||
// Rest of your function code here... | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
console.log('contentScriptForFdai.js loaded'); | ||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
console.log('contentScriptForFdai.js received a message', request); | ||
if (request.message === "getFdaiLocalStorage") { | ||
sendResponse({data: localStorage.getItem(request.key)}); | ||
} | ||
} | ||
); | ||
|
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
function showNotification(title, message) { | ||
chrome.notifications.create({ | ||
type: 'basic', | ||
iconUrl: 'icons/icon.png', // Path to the icon for the notification | ||
title: title, | ||
message: message | ||
}); | ||
} | ||
|
||
export async function extractAndSaveAmazon(html) { | ||
debugger | ||
|
||
html = html || document; | ||
|
||
const orderCards = html.querySelectorAll('.order-card'); | ||
let measurements = JSON.parse(localStorage.getItem('measurements')) || []; | ||
for (const orderCard of orderCards) { | ||
console.log('Order card:', orderCard); | ||
debugger | ||
let startAt = orderCard.querySelector('.delivery-box__primary-text').textContent.trim(); | ||
if(startAt === 'Order received') { | ||
continue; | ||
} | ||
if(startAt.includes('Arriving')) { | ||
continue; | ||
} | ||
startAt = startAt.replace('Delivered ', '').trim(); | ||
startAt = startAt + ', ' + new Date().getFullYear(); | ||
startAt = parseDate(startAt); | ||
const productBoxes = orderCard.querySelectorAll('.a-fixed-left-grid.item-box.a-spacing-small, .a-fixed-left-grid.item-box.a-spacing-none'); | ||
for (const box of productBoxes) { | ||
const image = box.querySelector('.product-image a img').src; | ||
const variableName = "Purchase of " + box.querySelector('.yohtmlc-product-title').textContent.trim(); | ||
const url = box.querySelector('.product-image a').href; | ||
|
||
showNotification('Saving Purchase Data', `Saving ${variableName} from Amazon`); | ||
|
||
|
||
// Check if the product is already in localStorage | ||
const isMeasurementStored = measurements.some(measurement => measurement.url === url && measurement.startAt === startAt); | ||
|
||
if (!isMeasurementStored) { | ||
|
||
// Add the product details to the array | ||
measurements.push({ | ||
startAt, | ||
variableName, | ||
unitName: "Count", | ||
value: 1, | ||
variableCategoryName: "Treatments", | ||
sourceName: "Amazon", | ||
url, | ||
image | ||
}); | ||
} | ||
} | ||
console.log(`Processed ${orderCards.length} products. Measurements:`, measurements); | ||
} | ||
|
||
if(typeof global.apiOrigin === 'undefined') { | ||
global.apiOrigin = 'https://safe.fdai.earth'; | ||
} | ||
|
||
if(measurements.length > 0) { | ||
console.log('Saving measurements:', measurements); | ||
const quantimodoAccessToken = await getQuantimodoAccessToken(); | ||
let input = global.apiOrigin + '/api/v1/measurements?XDEBUG_SESSION_START=PHPSTORM'; | ||
const response = await fetch(input, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Bearer ${quantimodoAccessToken}`, | ||
'X-CLIENT-ID': 'digital-twin-safe', | ||
}, | ||
body: JSON.stringify(measurements) | ||
}); | ||
// const response = await fetch('https://local.quantimo.do/api/v1/measurements', { | ||
// method: 'POST', | ||
// headers: { | ||
// 'Content-Type': 'application/json', | ||
// 'Authorization': `Bearer demo`, | ||
// }, | ||
// body: JSON.stringify([]) | ||
// }); | ||
if (!response.ok) { | ||
const text = await response.text(); | ||
console.error('Error response:', text); | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} else { | ||
const data = await response.json(); | ||
console.log('Post Measurement Response from API:', data); | ||
localStorage.setItem('measurements', JSON.stringify(measurements)); | ||
} | ||
} | ||
return measurements; | ||
|
||
} | ||
|
||
//module.exports = extractAndSaveAmazon; |
Oops, something went wrong.