KOJΛK
KOJΛK
PD🧩 Plasmo Developers
Created by KOJΛK on 11/23/2023 in #👟framework
refreshUncaught SyntaxError: Unexpected identifier 'HMR'
No description
2 replies
PD🧩 Plasmo Developers
Created by KOJΛK on 7/2/2023 in #👟framework
How to take a value from chrome to react stata?
Hello, i need to take the src value of this image :
<img class="captcha__image" src="https://us1.bumble.com/hidden?euri=PDj28x4e81zgy8w9S7RqGnsT5vcvlLQpUE2pBJDsprYcgl74N2hkJ50zWbe6JZtSLkil3oUrla8JBWWF27Sos1R-9jzsJqQvj-elJlhCRqKAFKSd3jWW1IV0Syr2mFwqML.m1SkAxuMphDOg1xsSMAu60acHVaq6TrYQi9bgVxUr0-0NY1gjBpgBbKxcvWZNa6UbmfwcjkFw-cF0fEN30yxHw3fS2sW18shfaJpwDRyanNCUQVeexA" alt="">
<img class="captcha__image" src="https://us1.bumble.com/hidden?euri=PDj28x4e81zgy8w9S7RqGnsT5vcvlLQpUE2pBJDsprYcgl74N2hkJ50zWbe6JZtSLkil3oUrla8JBWWF27Sos1R-9jzsJqQvj-elJlhCRqKAFKSd3jWW1IV0Syr2mFwqML.m1SkAxuMphDOg1xsSMAu60acHVaq6TrYQi9bgVxUr0-0NY1gjBpgBbKxcvWZNa6UbmfwcjkFw-cF0fEN30yxHw3fS2sW18shfaJpwDRyanNCUQVeexA" alt="">
So i did this code (simplified) :
const [url, setUrl] = useState("");

function start() {
chrome.scripting.executeScript({args: [number, password, url], target:{tabId: activeTabId}, func: test });
}

async function test() {

const imageUrl =
document.querySelector('.captcha__image').src;

const message = {
type: 'IMAGE_URL',
imageUrl: url
};
window.postMessage(message, '*');

const handleMessage = (event) => {
const { data } = event;
// console.log(data);
if (data && data.type === 'IMAGE_URL') {
const { imageUrl } = data;
setUrl(imageUrl);
}
};

window.addEventListener('message', handleMessage);
}
const [url, setUrl] = useState("");

function start() {
chrome.scripting.executeScript({args: [number, password, url], target:{tabId: activeTabId}, func: test });
}

async function test() {

const imageUrl =
document.querySelector('.captcha__image').src;

const message = {
type: 'IMAGE_URL',
imageUrl: url
};
window.postMessage(message, '*');

const handleMessage = (event) => {
const { data } = event;
// console.log(data);
if (data && data.type === 'IMAGE_URL') {
const { imageUrl } = data;
setUrl(imageUrl);
}
};

window.addEventListener('message', handleMessage);
}
The url state didn't change, even if i update if, if someone can helpme, thanks!
2 replies