Mastodon Filter TFOOT Fixer

Move TFOOT above TBODY on filter edit pages

当前为 2025-05-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         Mastodon Filter TFOOT Fixer
// @description  Move TFOOT above TBODY on filter edit pages
// @match        https://mastodon.social/filters/*/edit
// @version 0.0.1.20250521113020
// @namespace https://gf.qytechs.cn/users/1435046
// ==/UserScript==

if (/^\/filters\/\d+\/edit$/.test(location.pathname)) {
  const anchor = document.querySelector('a.add_fields');
  if (anchor) {

    // Change insertion method to 'prepend'
    anchor.setAttribute('data-association-insertion-method', 'prepend');

    const originalTfoot = anchor.closest('tfoot');
    if (originalTfoot) {
      // Grab the inner rows HTML
      const rowsHtml = originalTfoot.innerHTML;
      const table = originalTfoot.closest('table');
      const thead = table && table.querySelector('thead');
      if (table && thead) {
        // Remove the old tfoot
        originalTfoot.remove();
        // Create a new tbody, inject the rows
        const newTbody = document.createElement('tbody');
        newTbody.innerHTML = rowsHtml;
        // Insert right after the thead
        thead.insertAdjacentElement('afterend', newTbody);
      }
    }
  }
}

QingJ © 2025

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