Skip to content

Instantly share code, notes, and snippets.

@StackTrac3
Last active May 13, 2021 16:40
Show Gist options
  • Save StackTrac3/9c003d76291da1971d4764a0fb520ebe to your computer and use it in GitHub Desktop.
Save StackTrac3/9c003d76291da1971d4764a0fb520ebe to your computer and use it in GitHub Desktop.
(ES5 Compat) Greasemonkey Startpage Minimalistic/ Styling with config example
// ==UserScript==
// @name Startpage Options
// @grant GM_style.add
// @match *://startpage.com/*
// @match *://www.startpage.com/*
// @run-at document-begin
// ==/UserScript==
// Updated for May 2021 startpage element selector changes
(function() {
/* Configuration below
*/
var config = {
fullPage: {
// about inputPlaceholder: `true` for startpage default; `false` for nothing at all; `"string"` for your own text
inputPlaceholder: false,
// about pageTitle: `true` for startpage default; `false` for `Search``; `"string"` for your own text
pageTitle: false,
showSearchLogo: false,
showSearchSubtitle: false,
showPrivacyPlease: false
}
}
/* Configuration ends here
*/
var style = (function() {
var fullCss = ""
var domTargets = [
document.getElementsByTagName("head")[0],
document.createElement("style")
]
return {
append: function(css) { fullCss += css },
inject: function() {
domTargets[1].innerHTML = fullCss
domTargets[0].appendChild(domTargets[1])
}
}
})()
config = config.fullPage
var state = {
original: {
pageTitle: document.title
}
}
if (config.inputPlaceholder !== true) {
var input = document.getElementById("q")
if (input) { // search box does exist
input.placeholder = config.inputPlaceholder || ""
}
}
if (!config.showSearchSubtitle)
style.append(
".home__section-one__search-logo-container {" +
" display: none !important;" +
"}"
)
if (!config.showSearchLogo)
style.append(
".home__section-one__search-container > .subtitle {" +
" display: none !important;" +
"}"
)
if (!config.showPrivacyPlease)
style.append(
".hamburger-menu__privacy-please {" +
" display: none !important;" +
"}"
)
if (config.pageTitle !== true) {
document.title = config.pageTitle || "Search"
}
style.inject()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment