diff --git a/auto-wayfarer/autoWayfarerGemini.user.js b/auto-wayfarer/autoWayfarerGemini.user.js
index 729108d..f80c1b0 100644
--- a/auto-wayfarer/autoWayfarerGemini.user.js
+++ b/auto-wayfarer/autoWayfarerGemini.user.js
@@ -314,6 +314,53 @@
return urlsArray;
}
+ function extractJsonObjects(limit) {
+ // Set the default value of the limit parameter to Infinity
+ limit = limit || Infinity;
+
+ // Select all
elements with the class "font-medium"
+ const elements = document.querySelectorAll('div.font-medium');
+
+ // Initialize an empty array to store the JSON objects
+ const jsonObjects = [];
+
+ // Loop through the elements
+ for (const element of elements) {
+ // Extract the text inside the element
+ const text = element.textContent;
+
+ // Try to parse the text as JSON
+ try {
+ // Check if the text is a valid JSON object
+ if (text.startsWith('{') && text.endsWith('}')) {
+ // Parse the text as JSON
+ const jsonObject = JSON.parse(text);
+
+ // If the parsing is successful, add the JSON object to the array
+ jsonObjects.push(jsonObject);
+ } else {
+ // If the text is not a valid JSON object, try to parse it as a single property object
+ const jsonObject = JSON.parse(`{"data": "${text}"}`);
+
+ // If the parsing is successful, add the JSON object to the array
+ jsonObjects.push(jsonObject.data);
+ }
+ } catch (error) {
+ // If the parsing fails, log the text and the error message
+ console.error(`Failed to parse JSON from element: ${text}`);
+ console.error(error);
+ }
+
+ // If the limit has been reached, break the loop
+ if (jsonObjects.length >= limit) {
+ break;
+ }
+ }
+
+ // Return the array of JSON objects
+ return jsonObjects;
+ }
+
async function urlsToBlobs(imageUrls) {
const blobPromises = imageUrls.map(imageUrl => {
return fetch(imageUrl)
@@ -1060,7 +1107,7 @@
}
console.log('Question Informations (Review): ', questionResults);
await new Promise(resolve => setTimeout(resolve, 2000));
- possibleCategories = getPossibleCategories();
+ possibleCategories = getPossibleCategories();
if (possibleCategories) {
console.log('Possible Categories (Review): ', possibleCategories);
}
@@ -1074,10 +1121,13 @@
var maxIndex = Math.min(numImages, 4) - 1;
if (maxIndex > -1) {
+ var duplicateCheckTitles = extractJsonObjects(4)
+ console.log('Duplicate Check Titles (Review): ', duplicateCheckTitles);
for (let i = 0; i <= maxIndex; i++) {
if (!isSubmitted) {
var reviewImageDuplicate = await urlsToBlobs([mainPhoto, nearbyImages[i]])
- var reviewDuplicateFinalString = reviewDuplicateText + bottomText
+ var reviewDuplicateTitle = `Title of First image: ${title}\nTitle of Second image: ${duplicateCheckTitles[i]}`;
+ var reviewDuplicateFinalString = reviewDuplicateText + reviewDuplicateTitle + bottomText
reviewDuplicateChoice[i] = await geminiCallAPI(reviewDuplicateFinalString, reviewImageDuplicate)
if (Object.values(reviewDuplicateChoice[i])[0] === true) {
clickNearbyImages(i)