i am making a chrome extension. i need a text from an open website in the active tab of browser to use in javascript of the extension. how to fetch it in there?
like in this website link in this site i want the time fetched in the javascript. i am 2 hours ago started new. Please help with an example code if anyone can.
just show an example of how to store that text in a variable. thank you
for the manifest it should probably be fairly basic, you might want to restrict it to a single site and link some js to run so
manifest.json
{
"manifest_version": 3,
"name": "some name",
"version": "0.0.0",
"description": "description",
"content_scripts": [ {
"matches": ["https://www.utctime.net/ist-indian-time-now"],
"js": ["main.js"]
} ]
}
and the JS is pretty much getting the specific element, here it has an id named time so that can be used.
main.js
getTime = () =>{
time = document.getElementById("time").innerHTML
console.log(time)
}
setInterval(getTime, 100);