Remove startpage user script

This commit is contained in:
Simon Bruder 2021-01-04 21:57:02 +01:00
parent 9f39ee7ce4
commit 3304bf1b49
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -1,38 +0,0 @@
// ==UserScript==
// @name Startpage Bangs
// @version 1
// @grant none
// @run-at document-start
// @include https://*.startpage.com/*
// ==/UserScript==
fetch('https://s3.sbruder.de/cdn/bangs/bangs.json')
.then(text => text.json())
.then(bangs => {
const urlParams = new URLSearchParams(window.location.search)
const searchQuery = urlParams.get('query')
let matchBang = null
let parsedBang = null
matchBang = searchQuery.match(/(.*) \!(.*)/)
if (matchBang !== null) {
parsedBang = {
'bang': matchBang[2].toLowerCase(),
'query': matchBang[1]
}
}
matchBang = searchQuery.match(/\!(.*) (.*)/)
if (matchBang !== null) {
parsedBang = {
'bang': matchBang[1].toLowerCase(),
'query': matchBang[2]
}
}
if (parsedBang !== null) {
redirectURL = bangs[parsedBang.bang].replace('%s', encodeURI(parsedBang.query)).replace('%S', parsedBang.query)
window.location.replace(redirectURL);
}
})