Add files
This commit is contained in:
parent
9f7797e8df
commit
5934d96e8d
|
@ -0,0 +1,3 @@
|
||||||
|
# Multi engine Search
|
||||||
|
|
||||||
|
This Firefox extension allows you to use multiple of your installed search engines at once.
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "Multi engine search",
|
||||||
|
"version": "1.0",
|
||||||
|
|
||||||
|
"description": "Search on Multiple search engines.",
|
||||||
|
"homepage_url": "https://github.com/Javojav/Multi-engine-search",
|
||||||
|
|
||||||
|
"icons": {
|
||||||
|
"48": "icons/icon.png"
|
||||||
|
},
|
||||||
|
|
||||||
|
"permissions": [
|
||||||
|
"search"
|
||||||
|
],
|
||||||
|
|
||||||
|
"browser_action": {
|
||||||
|
"default_icon": "icons/icon.png",
|
||||||
|
"default_title": "Multi engine search",
|
||||||
|
"default_popup": "popup/search.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input type="text" id="searchbox" placeholder="Search"/>
|
||||||
|
<button type="button" class="search button">Search</button>
|
||||||
|
<br/>
|
||||||
|
<script src="search.js"></script>
|
||||||
|
<div id="boxes">
|
||||||
|
<button type="button" class="save default">Save selection as default</button>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,62 @@
|
||||||
|
browser.search.get().then(installedEngines);
|
||||||
|
|
||||||
|
let engineselection = [];
|
||||||
|
|
||||||
|
function search(tab) {
|
||||||
|
for (selected of engineselection) {
|
||||||
|
browser.search.search({
|
||||||
|
query: document.getElementById("searchbox").value,
|
||||||
|
engine: selected,
|
||||||
|
tabId: tab.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.browserAction.onClicked.addListener(search);
|
||||||
|
|
||||||
|
function saveselection() {
|
||||||
|
try {
|
||||||
|
localStorage.removeItem('defaultengines');
|
||||||
|
} catch {}
|
||||||
|
localStorage.setItem('defaultengines', engineselection);
|
||||||
|
}
|
||||||
|
|
||||||
|
function installedEngines(engines) {
|
||||||
|
for (engine of engines) {
|
||||||
|
let checkbox = document.createElement("INPUT");
|
||||||
|
checkbox.type = "checkbox";
|
||||||
|
checkbox.setAttribute('value', 'engine ' + engine.name);
|
||||||
|
try {
|
||||||
|
let defaultengines = localStorage.getItem('defaultengines').split(",");
|
||||||
|
for (eng of defaultengines) {
|
||||||
|
if (engine.name == eng) checkbox.checked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
|
let label = document.createElement('label');
|
||||||
|
label.appendChild(document.createTextNode(engine.name));
|
||||||
|
document.getElementById("boxes").appendChild(checkbox);
|
||||||
|
document.getElementById("boxes").appendChild(label);
|
||||||
|
|
||||||
|
let br = document.createElement("BR");
|
||||||
|
document.getElementById("boxes").appendChild(br)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", (e) => {
|
||||||
|
engineselection = [];
|
||||||
|
for (engine of document.getElementsByTagName('INPUT')) {
|
||||||
|
if (engine.value.includes("engine") && engine.checked) engineselection.push(engine.value.slice(7));
|
||||||
|
}
|
||||||
|
if (e.target.classList.contains("search")) {
|
||||||
|
browser.tabs.query({active: true, currentWindow: true})
|
||||||
|
.then(search);
|
||||||
|
} else if (e.target.classList.contains("default")) {
|
||||||
|
browser.tabs.query({active: true, currentWindow: true})
|
||||||
|
.then(saveselection);
|
||||||
|
} else if (e.target.classList.contains("image")) {
|
||||||
|
browser.tabs.query({active: true, currentWindow: true})
|
||||||
|
.then(searchimage);
|
||||||
|
}
|
||||||
|
});
|
Ŝarĝante…
Reference in New Issue