Skip to content

Instantly share code, notes, and snippets.

@LatinSuD
Created September 9, 2021 07:22
Show Gist options
  • Save LatinSuD/b86280e571ce7fb22b0e2808a0c99ab0 to your computer and use it in GitHub Desktop.
Save LatinSuD/b86280e571ce7fb22b0e2808a0c99ab0 to your computer and use it in GitHub Desktop.
Wiki.js search user script
// ==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