From aac76bfbc5c19824d0d84c77948fc628fa6f9902 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 12 Dec 2021 15:53:20 +0100 Subject: Commit --- assets/instant.js | 115 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 48 deletions(-) (limited to 'assets/instant.js') diff --git a/assets/instant.js b/assets/instant.js index bc643ab..3dbc0ac 100644 --- a/assets/instant.js +++ b/assets/instant.js @@ -1,66 +1,85 @@ (async () => { - instant = JSON.parse( - (await ( - await ( - await window.fetch("/ratelimited/instant.php?q=" + query) - ).blob() - ).text() - )); + try { + instant = JSON.parse( + (await ( + await ( + await window.fetch("/ratelimited/instant.php?q=" + query) + ).blob() + ).text() + )); - document.getElementById("details").innerHTML = "from DuckDuckGo:

" + instant.Abstract + "

" + instant.AbstractSource + "

"; + if (instant.Abstract.trim() !== "") { + document.getElementById("details").style.display = "block"; + document.getElementById("results").classList.add("with-details"); + try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} - if (instant.Abstract.trim() !== "") { - document.getElementById("details").style.display = "block"; - document.getElementById("results").classList.add("with-details"); - try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} - } else { - answer = (await ( + document.getElementById("details-inner").innerHTML = "from DuckDuckGo:

" + instant.Abstract + "

" + instant.AbstractSource + "

"; + } else { + answer = (await ( await ( await window.fetch("/ratelimited/answer.php?q=" + query) ).blob() ).text() ) - if (answer.trim() !== "Wolfram|Alpha did not understand your input" && answer.trim() !== "No short answer available") { - document.getElementById("details").innerHTML = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis information is provided by Wolfram|Alpha. Results and information from this site are not a certified or definitive source of information that can be relied on for legal, financial, medical, life-safety or any other critical purposes.

"; - document.getElementById("details").style.display = "block"; - document.getElementById("results").classList.add("with-details"); - try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + if (answer.trim() !== "Wolfram|Alpha did not understand your input" && answer.trim() !== "No short answer available" && answer.trim() !== "") { + document.getElementById("details-inner").innerHTML = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis information is provided by Wolfram|Alpha. Results and information from this site are not a certified or definitive source of information that can be relied on for legal, financial, medical, life-safety or any other critical purposes.

"; + document.getElementById("details").style.display = "block"; + document.getElementById("results").classList.add("with-details"); + try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + } else { + document.getElementById("details").style.display = "none"; + } } - } - if (!instant._WolfEye_External) { - try { document.getElementById("details-source").innerHTML = " " } catch (e) {} - try { document.getElementById("details-data-link").target = "" } catch (e) {} - } + if (!instant._WolfEye_External) { + try { document.getElementById("details-source").innerHTML = " " } catch (e) {} + try { document.getElementById("details-data-link").target = "" } catch (e) {} + } + + if (instant.Results[0]) { + if (!document.getElementsByClassName("result-official")[0]) { + document.getElementById("results").innerHTML = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + } - if (instant.Results[0]) { - if (!document.getElementsByClassName("result-official")[0]) { - document.getElementById("results").innerHTML = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + document.getElementsByClassName("result-official")[0].classList.add("result-verified"); + document.getElementsByClassName("result-official")[0].children[0].href = instant.Results[0].FirstURL; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "https://duckduckgo.com" + instant.Results[0].Icon.URL; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = instant.Heading; + document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = instant.Results[0].FirstURL; } - document.getElementsByClassName("result-official")[0].classList.add("result-verified"); - document.getElementsByClassName("result-official")[0].children[0].href = instant.Results[0].FirstURL; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "https://duckduckgo.com" + instant.Results[0].Icon.URL; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = instant.Heading; - document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = instant.Results[0].FirstURL; - } + if (query === "wolfeye" || query === "wolf eye") { + document.getElementById("details-inner").innerHTML = "

Hold tight! Let's go home...

You are already using WolfEye; but you seem lost. Use the search bar at the top of this page to search for something on the Web.

" + document.getElementById("details-inner").style.display = "block"; - if (query === "wolfeye" || query === "wolf eye") { - document.getElementById("details").innerHTML = "

Hold tight! Let's go home...

You are already using WolfEye; but you seem lost. Use the search bar at the top of this page to search for something on the Web.

" - document.getElementById("details").style.display = "block"; + if (!document.getElementsByClassName("result-official")[0]) { + document.getElementById("results").innerHTML = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + } - if (!document.getElementsByClassName("result-official")[0]) { - document.getElementById("results").innerHTML = '
Example
https://example.com/
' + document.getElementById("results").innerHTML; + document.getElementsByClassName("result-official")[0].classList.add("result-verified"); + document.getElementsByClassName("result-official")[0].children[0].href = "https://wolfeye.minteck.org"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "/logo.svg"; + document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = "WolfEye"; + document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = "https://wolfeye.minteck.org"; + } + } catch (e) { + answer = (await ( + await ( + await window.fetch("/ratelimited/answer.php?q=" + query) + ).blob() + ).text() + ) + if (answer.trim() !== "Wolfram|Alpha did not understand your input" && answer.trim() !== "No short answer available" && answer.trim() !== "") { + document.getElementById("details-inner").innerHTML = "from Wolfram|Alpha:

" + answer + "

DisclaimerThis information is provided by Wolfram|Alpha. Results and information from this site are not a certified or definitive source of information that can be relied on for legal, financial, medical, life-safety or any other critical purposes.

"; + document.getElementById("details").style.display = "block"; + document.getElementById("results").classList.add("with-details"); + try {document.getElementsByClassName("dym-section")[0].outerHTML = ""; } catch (e) {} + } else { + document.getElementById("details").style.display = "none"; } - - document.getElementsByClassName("result-official")[0].classList.add("result-verified"); - document.getElementsByClassName("result-official")[0].children[0].href = "https://wolfeye.minteck.org"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].src = "/assets/verified.svg"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[2].title = "Verified Website"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[0].src = "/logo.svg"; - document.getElementsByClassName("result-official")[0].children[0].children[0].children[1].innerText = "WolfEye"; - document.getElementsByClassName("result-official")[0].children[0].children[1].children[0].innerText = "https://wolfeye.minteck.org"; } })() \ No newline at end of file -- cgit