74,75c74,78 < var search = "https://duckduckgo.com/"; // The search engine < var query = "q"; // The query variable name for the search engine --- > var search = { > "default": "https://duckduckgo.com/", > "g": "https://google.com/search", > "s": "https://startpage.com/do/search" > }; 91,110c94,122 < match = new RegExp(regex ? regex : ".", "i"); < gmatches = false; // kinda ugly, rethink < for (i = 0; i < Object.keys(sites).length; i++) { < matches = false; < sn = Object.keys(sites)[i]; < section = document.createElement("div"); < section.id = sn; < section.innerHTML = sn; < section.className = "section"; < inner = document.createElement("div"); < for (l = 0; l < Object.keys(sites[sn]).length; l++) { < ln = Object.keys(sites[sn])[l]; < if (match.test(ln)) { < link = document.createElement("a"); < link.href = sites[sn][ln]; < link.innerHTML = ln; < if (!pivotbuffer++ && regex != "") { < link.className = "selected"; < document.getElementById("action").action = sites[sn][ln]; < document.getElementById("action").children[0].removeAttribute("name"); --- > if (regex.charAt(1) == ' ' && search.hasOwnProperty(regex.charAt(0))) { > document.getElementById("action").action = search[regex.charAt(0)]; > document.getElementById("action").children[0].name = "q"; > } else { > match = new RegExp(regex ? regex : ".", "i"); > gmatches = false; // kinda ugly, rethink > for (i = 0; i < Object.keys(sites).length; i++) { > matches = false; > sn = Object.keys(sites)[i]; > section = document.createElement("div"); > section.id = sn; > section.innerHTML = sn; > section.className = "section"; > inner = document.createElement("div"); > for (l = 0; l < Object.keys(sites[sn]).length; l++) { > ln = Object.keys(sites[sn])[l]; > if (match.test(ln)) { > link = document.createElement("a"); > link.href = sites[sn][ln]; > link.innerHTML = ln; > if (!pivotbuffer++ && regex != "") { > link.className = "selected"; > document.getElementById("action").action = sites[sn][ln]; > document.getElementById("action").children[0].removeAttribute("name"); > } > inner.appendChild(link); > matches = true; > gmatches = true; > totallinks++; 112,115d123 < inner.appendChild(link); < matches = true; < gmatches = true; < totallinks++; 116a125,130 > section.appendChild(inner); > matches ? p.appendChild(section) : false; > } > if (!gmatches || regex == "") { > document.getElementById("action").action = search["default"]; > document.getElementById("action").children[0].name = "q"; 118,123d131 < section.appendChild(inner); < matches ? p.appendChild(section) : false; < } < if (!gmatches || regex == "") { < document.getElementById("action").action = search; < document.getElementById("action").children[0].name = query; 157a167,173 > document.getElementById("action").onsubmit = function() { > svalue = this.children[0].value; > if (svalue.charAt(1) == ' ' && search.hasOwnProperty(svalue.charAt(0))) { > this.children[0].value = svalue.substring(2); > } > return true; > }