Answer the question
In order to leave comments, you need to log in
How to call an event on a page using a Chrome extension?
Hello!
I am writing an extension for Chrome
The extension should automatically fill out the form on the page and submit it when the button in the popup's
manifest.json is clicked:
{
"manifest_version": 2,
"name": "Time to bot it",
"description": "So many pages",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs", "http://*/*", "https://*/*", "background", "browsingData", "contextMenus", "cookies"
]
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Time to bot it!</title>
<script src="jquery.js"></script>
<script src="script.js"></script>
</head>
<body>
<input type="button" class="bt" value="Button"/>
<div class="res"></div>
</body>
</html>
$(document).ready(function(){
$('input').click(function(e){
chrome.tabs.executeScript(null, {file:"click.js"});
});
});
$(document).ready(function(){
$('input').trigger('click');
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$('.bt').click(function(){
$('.num').html($('.num').html()*1+1);
});
});
</script>
</head>
<body>
<input type="button" class="bt" id="bt" value="Click!"/>
<div class="num">0</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question