Quick filter Mount&Blade operations from the wiki

Add a small input box to look-up, find and filter specific operations.

目前為 2025-07-21 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Quick filter Mount&Blade operations from the wiki
// @description Add a small input box to look-up, find and filter specific operations.
// @namespace   https://gf.qytechs.cn/users/4813
// @match       https://mbcommands.fandom.com/wiki/Operations*
// @match       https://antifandom.com/mbcommands/wiki/Operations*
// @version     2025.07.21
// @author      Swyter
// @license     GNU GPLv3
// @grant       none
// ==/UserScript==

search=document.createElement("input")
search.setAttribute("type", "text")
search.setAttribute("placeholder", "Filter operations...")
search.setAttribute("style", "/*! position: relative; */align-self: center;/*! display: inline-grid; */width: calc(100% - 40%);left: calc(20%);position: fixed;bottom: 20px;")
document.body.appendChild(search)

style=document.createElement("style")
style.textContent = `
.operation[hidden],
.operation[hidden] + dl,
body[opfilter] .mw-parser-output p:not(.operation),
body[opfilter] .mw-parser-output pre,
body[opfilter] .mw-parser-output ol,
body[opfilter] .mw-parser-output ul,
body[opfilter] .mw-parser-output *:not(.operation) + dl,
body[opfilter] .mw-parser-output div
{
  display: none;
}
`

document.body.appendChild(style)

search.oninput=function(e)
{
  /* swy: hide all the non-operation stuff when using the search box; make it clean */
  document.body.setAttribute("opfilter", "true")

  //console.log(e, e.target.value);
  operations = document.querySelectorAll(".operation");
  search_text= e.target.value

  for (var op of operations)
  {
    //console.log(op)
    if (op.id.includes(search_text))
      op.removeAttribute("hidden")
    else
      op.setAttribute("hidden", "true")
  }

}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址