The idea was to make a simple Chrome Extension to make a Google search on the specific site instead of writing a site:whatever.whatever in a Google search field. Here's my popup.html:
<html>
<head>
<title>HTP Searcher Extension's Popup</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form action="https://www.google.com/search" method="get" target="_blank" onsubmit="companiesSearch()">
<input type="text" id="finalquery" name="q" value="" style="display:none;">
<input type="text" id="site" name="othername" value=" site:www.park.by" style="display:none;">
<input type="text" id="entertext" name="entertext">
<input type="submit" class="sendsubmit" name="submit">
</form>
</body>
</html>
And popup.js:
function companiesSearch() {
var value1 = document.getElementById('entertext').value;
var value2 = document.getElementById('site').value;
var value3 = value1 + value2;
document.getElementById('finalquery').setAttribute('value', value3);
}
If to make a simple html file + js file like in the construction above, everything works smoothly. If to make it an extension, it works only without adding javascript: if to make an easy one input form it opens a new tab and shoes the search results. But after adding a script and after submit the search request blinks in the url line and than an empty Google search appears. Such error can by seen in console:
Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported
at newtab-serviceworker.js:61
at <anonymous>
By the way, my manifest.json:
{
"manifest_version": 2,
"name": "HTP Searcher",
"description": "This extension searches companies",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["popup.js"]
},
"permissions": [
"activeTab",
"tabs",
"https://ajax.googleapis.com/"
]
}
Thank everyone in advance, completely new to writing extensions.