Answer the question
In order to leave comments, you need to log in
Call function in chrome extension from python or from console?
How to call a function in chrome extension from python selenium or from console while on website
Function in extension
function showMessage(text) {
alert( text );
}
and through python or console call this function
showMessage('Hello everyone!')
if called in Console while on the site, it does not see this function, it only sees it if you go to the extension settings page
Answer the question
In order to leave comments, you need to log in
Inject a function into the page, then you can call it from the console on the page
InjectFunction = function(PageScriptSpace, func) {
PageScriptSpace.innerHTML += func;
}
PageScriptSpace = document.createElement('script');
InjectFunction(PageScriptSpace, showMessage);
document.querySelector('head').appendChild(PageScriptSpace);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question