From 2f567cb4eed6bae3d41c2b68268c6f42993e0ded Mon Sep 17 00:00:00 2001 From: static Date: Sat, 25 Feb 2023 18:48:35 +0000 Subject: [PATCH] Add lang parameter to forms Fixes searching when using non-default languages --- src/utils.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/utils.js b/src/utils.js index 0e5961d..835ec49 100644 --- a/src/utils.js +++ b/src/utils.js @@ -140,6 +140,12 @@ module.exports = function(redis) { } } + // add the lang query param to forms + let forms = data.html.querySelectorAll('form') + for(let i = 0; i < forms.length; i++) { + forms[i].insertAdjacentHTML('afterbegin', ``) + } + // remove #p-wikibase-otherprojects let wikibase_links = data.html.querySelector('#p-wikibase-otherprojects') if(wikibase_links) { @@ -201,18 +207,6 @@ module.exports = function(redis) { const wiki_href_regx = /(href=\"(https:|http:|)\/\/([A-z.-]+\.)?(wikipedia.org|wikimedia.org|wikidata.org|mediawiki.org))/gm data.html = data.html.replace(wiki_href_regx, 'href="') - /** - * If we are on DownloadAsPdf page, we have to inject a input which - * holds the language value. Without this input, we can't access the - * language (not avail from the POST data). - * See more on https://codeberg.org/orenom/Wikiless/issues/9 - */ - if(url.includes('%3ADownloadAsPdf')) { - let lang_input = `` - let replace_str = `