From 2565d70bc21792d37b37e0f3930bb412b5d7d6cb Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sun, 25 Jul 2021 09:17:30 -0400 Subject: [PATCH] attempt to counteract popular search engine subversions --- .../DDG search engine counter optimization.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 greasemonkey/DDG search engine counter optimization.js diff --git a/greasemonkey/DDG search engine counter optimization.js b/greasemonkey/DDG search engine counter optimization.js new file mode 100644 index 0000000..af4139c --- /dev/null +++ b/greasemonkey/DDG search engine counter optimization.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name DDG search engine counter-optimization +// @version 1 +// @grant none +// @description SEO has really subverted search engines +// @include /^https?://(www\.)?duckduckgo.com/ +// @namespace adamrgrey.com +// @license MIT +// ==/UserScript== + +let thisYear = new Date().getYear() + 1900; +let searchEngineConfounders = ["in " + thisYear, "in " + (thisYear - 1), "in " + (thisYear), "best", "top 10"]; + +window.onload = function(event) { + clearInput(document.querySelector("#search_form_input_homepage")); + clearInput(document.querySelector("#search_form_input")); +}; + +function clearInput(input){ + if(input === null){ + return; + } + let currentQuery = input.value; + + searchEngineConfounders.forEach((elem) => { + let subtractor = "-\"" + elem + "\""; + if(currentQuery.indexOf(subtractor) < 0){ + input.value += " " + subtractor; + } + }); +} \ No newline at end of file