mirror of
https://wiilab.wiimart.org/wiimart/wiimart-extension
synced 2025-09-03 20:11:04 +02:00
updates???
This commit is contained in:
parent
3488c3f219
commit
20cfc4dbc0
@ -48,6 +48,7 @@ chrome.webRequest.onBeforeRequest.addListener(
|
|||||||
// GET Requests
|
// GET Requests
|
||||||
if (params.has('get')) {
|
if (params.has('get')) {
|
||||||
const key = params.get('get');
|
const key = params.get('get');
|
||||||
|
console.log("Get key: " + key)
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
chrome.storage.local.get(key, result => {
|
chrome.storage.local.get(key, result => {
|
||||||
if (key === 'logs') {
|
if (key === 'logs') {
|
||||||
@ -71,8 +72,9 @@ chrome.webRequest.onBeforeRequest.addListener(
|
|||||||
if (params.has('set_key')) {
|
if (params.has('set_key')) {
|
||||||
const key = params.get('set_key');
|
const key = params.get('set_key');
|
||||||
const value = params.get('set_value');
|
const value = params.get('set_value');
|
||||||
|
console.log("Set key: " + key + " with value: " + value)
|
||||||
if (key === 'slogs') {
|
if (key === 'slogs') {
|
||||||
|
console.log("Set key: logs with value: " + value)
|
||||||
logs.push(`[SET] ${new Date().toISOString()}: ${value}`);
|
logs.push(`[SET] ${new Date().toISOString()}: ${value}`);
|
||||||
chrome.storage.local.set({ logs });
|
chrome.storage.local.set({ logs });
|
||||||
} else {
|
} else {
|
||||||
@ -83,10 +85,33 @@ chrome.webRequest.onBeforeRequest.addListener(
|
|||||||
|
|
||||||
// CLEAR Logs
|
// CLEAR Logs
|
||||||
if (params.has('clogs')) {
|
if (params.has('clogs')) {
|
||||||
|
console.log("Clear Logs")
|
||||||
logs = [];
|
logs = [];
|
||||||
chrome.storage.local.set({ logs: [] });
|
chrome.storage.local.set({ logs: [] });
|
||||||
return { cancel: true };
|
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*"] },
|
{ urls: ["*://*/_extension_storage*"] },
|
||||||
|
@ -17,27 +17,12 @@ window.tsz = tsz;
|
|||||||
window.ttmdsz = ttmdsz;
|
window.ttmdsz = ttmdsz;
|
||||||
window.lv = lv;
|
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
|
// Define the trace function
|
||||||
const trace = function(...args) {
|
const trace = function(...args) {
|
||||||
extensionStorage.slog(...args)
|
extensionStorage.slog(...args)
|
||||||
console.log(...args);
|
console.log(...args);
|
||||||
//console.trace(...args);
|
//console.trace(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
|
||||||
console.log("Current points:", points);
|
|
||||||
|
|
||||||
// content-script.js
|
// content-script.js
|
||||||
const storageCache = {};
|
const storageCache = {};
|
||||||
const STORAGE_ENDPOINT = '/_extension_storage';
|
const STORAGE_ENDPOINT = '/_extension_storage';
|
||||||
@ -82,9 +67,31 @@ const extensionStorage = {
|
|||||||
fetch(`${STORAGE_ENDPOINT}?clogs=true`)
|
fetch(`${STORAGE_ENDPOINT}?clogs=true`)
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
storageCache.logs = [];
|
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
|
// Define the ECommerceInterface class
|
||||||
class ECommerceInterface {
|
class ECommerceInterface {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -106,7 +113,6 @@ class ECommerceInterface {
|
|||||||
}],
|
}],
|
||||||
]);
|
]);
|
||||||
trace("ECommerceInterface initialized"); // Use the trace function
|
trace("ECommerceInterface initialized"); // Use the trace function
|
||||||
this.loadPoints(); // Load data when the class is instantiated
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getTicketInfos(titleId) {
|
getTicketInfos(titleId) {
|
||||||
@ -139,11 +145,11 @@ class ECommerceInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getLog() {
|
getLog() {
|
||||||
return extensionStorage.getLogs || ""; // Return the stored trace or an empty string
|
return extensionStorage.getLogs() || ""; // Return the stored trace or an empty string
|
||||||
}
|
}
|
||||||
|
|
||||||
getPoints() {
|
getPoints() {
|
||||||
return points; // Return the current points
|
return extensionStorage.getpts() || 0; // Return the current points
|
||||||
}
|
}
|
||||||
|
|
||||||
setPoints(newPoints) {
|
setPoints(newPoints) {
|
||||||
@ -156,17 +162,12 @@ class ECommerceInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPoints = parseInt(window.localStorage.getItem('points'), 10) || 0;
|
extensionStorage.spts(newPoints);
|
||||||
points = currentPoints + newPoints;
|
trace("Points updated to: " + extensionStorage.getpts());
|
||||||
window.localStorage.setItem('points', points);
|
|
||||||
trace("Points updated to: " + points);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPoints() {
|
loadPoints() {
|
||||||
const storedPoints = window.localStorage.getItem('points');
|
console.log("nah i dont load points, they alr loaded");
|
||||||
if (storedPoints) {
|
|
||||||
points = parseInt(storedPoints, 10); // Set points to the stored value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelOperation() {
|
cancelOperation() {
|
||||||
@ -239,7 +240,7 @@ class ECommerceInterface {
|
|||||||
return extensionStorage.get(key);
|
return extensionStorage.get(key);
|
||||||
}
|
}
|
||||||
pubKeyEncrypt(nah) {
|
pubKeyEncrypt(nah) {
|
||||||
console.log("behonest this is not required: " + nah)
|
console.log("behonest this is not required: " + nah);
|
||||||
return nah;
|
return nah;
|
||||||
}
|
}
|
||||||
purchasePoints(pointsToBuy, itemId, price, payment, taxes, purchaseInfo, discount) {
|
purchasePoints(pointsToBuy, itemId, price, payment, taxes, purchaseInfo, discount) {
|
||||||
@ -407,8 +408,6 @@ class wiiDlTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.ECommerceInterface = ECommerceInterface;
|
window.ECommerceInterface = ECommerceInterface;
|
||||||
var etraceinterfacey = ECommerceInterface;
|
|
||||||
console.log("Trace loaded:", etraceinterfacey.getLog());
|
|
||||||
window.ECCreditCardEncryptedPayment = ECCreditCardEncryptedPayment;
|
window.ECCreditCardEncryptedPayment = ECCreditCardEncryptedPayment;
|
||||||
window.ECPrice = ECPrice;
|
window.ECPrice = ECPrice;
|
||||||
window.wiiKeyboard = wiiKeyboard;
|
window.wiiKeyboard = wiiKeyboard;
|
||||||
|
7
popup.js
7
popup.js
@ -1,11 +1,14 @@
|
|||||||
// popup.js
|
// popup.js
|
||||||
|
const STORAGE_ENDPOINT = '/_extension_storage';
|
||||||
document.getElementById('clearTrace').addEventListener('click', function() {
|
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('cleared').textContent = 'Cleared: trace';
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('clearPoints').addEventListener('click', function() {
|
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';
|
document.getElementById('cleared').textContent = 'Cleared: points';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user