I am just learning JavaScript primarily to automate searches on a specific website and compare some data that is gathered from those searches. Thus I was wondering if it would be possible to do such a thing with a search bar in that site with JavaScript in my chrome extension I want to create.
Note: an example of a search bar in a website would be like YouTube's search bar
Edit: After doing far more research, I found that forum.submit
might be of use, but I am not too sure.
EDIT 2:
extension_ui.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>extension_ui</title>
</head>
<body>
<button>Start</button>
<script src="find_time_slots.js" charset="utf-8"></script>
</body>
</hmtl>
find_time_slots.js
document.addEventListener('DOMContentLoaded', function(){
document.querySelector('button').addEventListener('click',onclick,false)
function onclick(res){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
res.tabNum,
{code: 'document.getElementById("search").value = "overwatch";'}
);
})
}
},false)
content.js
chrome.runtime.onMessage.addListener(function(request,sender,sendResponse){
sendResponse({tabNum: sender.id})
});
Although I am not getting any errors, it does not update the search bar(on youtube) to ethier have "overwatch" as its value or show up in the youtube page.