updates???

This commit is contained in:
thom2305 2025-05-08 14:42:12 -04:00
parent 3488c3f219
commit 20cfc4dbc0
No known key found for this signature in database
GPG Key ID: 0171038FEE1BEF12
3 changed files with 59 additions and 32 deletions

View File

@ -48,6 +48,7 @@ chrome.webRequest.onBeforeRequest.addListener(
// GET Requests
if (params.has('get')) {
const key = params.get('get');
console.log("Get key: " + key)
return new Promise(resolve => {
chrome.storage.local.get(key, result => {
if (key === 'logs') {
@ -71,8 +72,9 @@ chrome.webRequest.onBeforeRequest.addListener(
if (params.has('set_key')) {
const key = params.get('set_key');
const value = params.get('set_value');
console.log("Set key: " + key + " with value: " + value)
if (key === 'slogs') {
console.log("Set key: logs with value: " + value)
logs.push(`[SET] ${new Date().toISOString()}: ${value}`);
chrome.storage.local.set({ logs });
} else {
@ -83,10 +85,33 @@ chrome.webRequest.onBeforeRequest.addListener(
// CLEAR Logs
if (params.has('clogs')) {
console.log("Clear Logs")
logs = [];
chrome.storage.local.set({ logs: [] });
return { cancel: true };
}
if (params.has('set_key') && params.get('set_key') === 'spts') {
const pointsToAdd = parseInt(params.get('set_value')) || 0;
chrome.storage.local.get(['pts'], (result) => {
const currentPoints = parseInt(result.pts) || 0;
const newTotal = currentPoints + pointsToAdd;
// Update both in-memory and storage
logs.push(`[POINTS] Added ${pointsToAdd} points (Total: ${newTotal})`);
chrome.storage.local.set({
pts: newTotal,
logs
});
});
return { cancel: true };
}
if (params.has('cpts')) {
console.log("Clear Points")
chrome.storage.local.set({ pts: 0 });
return { cancel: true };
}
}
},
{ urls: ["*://*/_extension_storage*"] },

View File

@ -17,27 +17,12 @@ window.tsz = tsz;
window.ttmdsz = ttmdsz;
window.lv = lv;
var points = 0; // Initialize points
// Load the existing trace and points from localStorage
const loadData = () => {
const storedPoints = window.localStorage.getItem('points');
if (storedPoints) {
points = parseInt(storedPoints, 10); // Set points to the stored value
}
};
// Define the trace function
const trace = function(...args) {
extensionStorage.slog(...args)
console.log(...args);
//console.trace(...args);
};
loadData();
console.log("Current points:", points);
// content-script.js
const storageCache = {};
const STORAGE_ENDPOINT = '/_extension_storage';
@ -82,9 +67,31 @@ const extensionStorage = {
fetch(`${STORAGE_ENDPOINT}?clogs=true`)
.catch(() => {});
storageCache.logs = [];
},
spts: (points) => {
const pointsToAdd = parseInt(points) || 0;
if (pointsToAdd > 0) {
fetch(`${STORAGE_ENDPOINT}?set_key=spts&set_value=${pointsToAdd}`)
.catch(() => {});
}
},
getpts: () => {
const points = extensionStorage.get('pts');
return parseInt(points) || 0;
},
clearpts: () => {
fetch(`${STORAGE_ENDPOINT}?cpts=true`)
.catch(() => {});
storageCache.pts = 0;
}
};
console.log("Current points:", extensionStorage.getpts());
console.log("Trace loaded:", extensionStorage.getLogs());
// Define the ECommerceInterface class
class ECommerceInterface {
constructor() {
@ -106,7 +113,6 @@ class ECommerceInterface {
}],
]);
trace("ECommerceInterface initialized"); // Use the trace function
this.loadPoints(); // Load data when the class is instantiated
}
getTicketInfos(titleId) {
@ -139,11 +145,11 @@ class ECommerceInterface {
}
}
getLog() {
return extensionStorage.getLogs || ""; // Return the stored trace or an empty string
return extensionStorage.getLogs() || ""; // Return the stored trace or an empty string
}
getPoints() {
return points; // Return the current points
return extensionStorage.getpts() || 0; // Return the current points
}
setPoints(newPoints) {
@ -156,17 +162,12 @@ class ECommerceInterface {
return;
}
const currentPoints = parseInt(window.localStorage.getItem('points'), 10) || 0;
points = currentPoints + newPoints;
window.localStorage.setItem('points', points);
trace("Points updated to: " + points);
extensionStorage.spts(newPoints);
trace("Points updated to: " + extensionStorage.getpts());
}
loadPoints() {
const storedPoints = window.localStorage.getItem('points');
if (storedPoints) {
points = parseInt(storedPoints, 10); // Set points to the stored value
}
console.log("nah i dont load points, they alr loaded");
}
cancelOperation() {
@ -239,7 +240,7 @@ class ECommerceInterface {
return extensionStorage.get(key);
}
pubKeyEncrypt(nah) {
console.log("behonest this is not required: " + nah)
console.log("behonest this is not required: " + nah);
return nah;
}
purchasePoints(pointsToBuy, itemId, price, payment, taxes, purchaseInfo, discount) {
@ -407,8 +408,6 @@ class wiiDlTask {
}
window.ECommerceInterface = ECommerceInterface;
var etraceinterfacey = ECommerceInterface;
console.log("Trace loaded:", etraceinterfacey.getLog());
window.ECCreditCardEncryptedPayment = ECCreditCardEncryptedPayment;
window.ECPrice = ECPrice;
window.wiiKeyboard = wiiKeyboard;

View File

@ -1,11 +1,14 @@
// popup.js
const STORAGE_ENDPOINT = '/_extension_storage';
document.getElementById('clearTrace').addEventListener('click', function() {
window.localStorage.setItem('thetrace', ''); // Clear the 'thetrace' variable
fetch(`${STORAGE_ENDPOINT}?clogs=true`)
.catch(() => {});
document.getElementById('cleared').textContent = 'Cleared: trace';
});
document.getElementById('clearPoints').addEventListener('click', function() {
window.localStorage.setItem('points', ''); // Clear the 'points' variable
fetch(`${STORAGE_ENDPOINT}?cpts=true`)
.catch(() => {});
document.getElementById('cleared').textContent = 'Cleared: points';
});