Created
December 1, 2021 22:45
-
-
Save cking/7c183b42eb1dc7a49a4d4d7048add89b to your computer and use it in GitHub Desktop.
universalis
This file contains 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 Search get parameter - universalis.app | |
// @namespace Z0ne | |
// @match https://universalis.app/ | |
// @grant none | |
// @version 1.0 | |
// @author Kura | |
// @description Get a search term from a query get parameter | |
// ==/UserScript== | |
const query = location.search.substring(1) | |
if (!query.length) { | |
return | |
} | |
const queryParts = query.split("&").map(v => { | |
const key = v.split("=", 1)[0] | |
const value = decodeURIComponent(v.substring(key.length + 1).replace("+", "%20")) | |
return [key, value] | |
}) | |
const queryMap = {} | |
for (let pair of queryParts) { | |
queryMap[pair[0]] = pair[1] | |
} | |
if (!queryMap.q) { | |
return | |
} | |
const searchBar = document.querySelector(".search") | |
searchBar.value = queryMap.q | |
var ev = new KeyboardEvent("keyup", {keyCode: 13}) | |
searchBar.dispatchEvent(ev) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment