Created
December 9, 2020 09:26
-
-
Save josefandersson/402517303d1cfed81ea1e40193939fd2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name DuckDuckGo Force Strict | |
// @namespace - | |
// @version 1.0 | |
// @description Force 'strict' search mode on DuckDuckGo. | |
// @author Josef Andersson | |
// @include *://duckduckgo.com/?* | |
// @icon https://duckduckgo.com/favicon.ico | |
// @grant GM_addStyle | |
// ==/UserScript== | |
// SAFE SEARCH BUTTON TEXT TO LOOK FOR | |
// If you change duckduckgo language this will have to change. | |
// Changing this to any of 'Strict', 'Moderate' or 'Off' will force that mode. (Case-sensitive!!) | |
const SEARCH_MODE_TEXT = 'Strict'; | |
GM_addStyle('.dropdown--safe-search { display:none !important; }'); | |
const dropdown = document.querySelector('.dropdown--safe-search a'); | |
if (dropdown && dropdown.innerText.indexOf(SEARCH_MODE_TEXT) < 0) { | |
dropdown.click(); | |
const id = setInterval(() => { | |
const res = document.querySelectorAll('.modal--dropdown--safe-search li a'); | |
if (res.length) { | |
clearInterval(id); | |
res.forEach(a => { | |
if (-1 < a.innerText.indexOf(SEARCH_MODE_TEXT)) | |
a.click(); | |
}); | |
} | |
}, 30); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment