Created
September 9, 2021 07:22
-
-
Save LatinSuD/b86280e571ce7fb22b0e2808a0c99ab0 to your computer and use it in GitHub Desktop.
Wiki.js search user script
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 Wiki.js Search | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://mydomain.com/?search=* | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
/***** | |
Please edit the "@match" line above to match your URL | |
*****/ | |
(function() { | |
'use strict'; | |
function querySelectorIncludesText (selector, text){ | |
return Array.from(document.querySelectorAll(selector)) | |
.find(el => el.textContent.includes(text)); | |
} | |
var inter=setInterval(function() { | |
var b=querySelectorIncludesText('LABEL','Buscar...'); | |
if (b) { | |
var b2=document.getElementById(b.getAttribute('for')) | |
if (b2) { | |
b2.value=location.href.replace(/[^?]*\?search=/,"") | |
console.log("Lanzando busqueda " + b2.value) | |
b2.dispatchEvent(new KeyboardEvent('input',{'key':'a'})); | |
clearInterval(inter); | |
} | |
} | |
}, 50) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment