Add Advanced Search Button - twitter.com

4/28/2022, 9:50:18 PM

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Add Advanced Search Button - twitter.com
// @namespace   Violentmonkey Scripts
// @match       https://twitter.com/*
// @grant       none
// @version     1.1
// @author      OnkelTem
// @description 4/28/2022, 9:50:18 PM
// @license     MIT
// ==/UserScript==

const titleText = "Advanced Search";
const svgIconHtml = '<g><path d="m10 2.7714c4.0001 0 7.2429 3.2427 7.2429 7.2429 0 1.794-0.65743 3.4431-1.7383 4.7134l0.30086 0.30086h0.88028l5.5714 5.5714-1.6714 1.6714-5.5714-5.5714v-0.88028l-0.30086-0.30086c-1.2703 1.0809-2.9194 1.7383-4.7134 1.7383-4.0001 0-7.2429-3.2427-7.2429-7.2429 0-4.0001 3.2427-7.2429 7.2429-7.2429m0 2.2286c-2.7857 0-5.0143 2.2286-5.0143 5.0143 0 2.7857 2.2286 5.0143 5.0143 5.0143 2.7857 0 5.0143-2.2286 5.0143-5.0143 0-2.7857-2.2286-5.0143-5.0143-5.0143z"/></g>';

function main(nav) {
  const l = nav.querySelector('a').cloneNode(true);
  l.setAttribute('aria-label', titleText);
  l.href = "https://twitter.com/search-advanced?lang=en";
  const svg = l.querySelector('svg');
  const span = l.querySelector('span');
  span.textContent = titleText;
  span.style.fontWeight = 'normal';
  svg.innerHTML = svgIconHtml;
  nav.appendChild(l);
}

new MutationObserver((list, o) => {
  for (const m of list) {
    if (m.type === 'childList') {
      let nodes = m.addedNodes;
      for (let n of nodes) {
        const nav = n.querySelector('nav[role="navigation"]');
        if (nav != null) {
          o.disconnect();
          main(nav);
        }
      }
    }
  }
}).observe(document.getElementById('react-root'), {childList: true, subtree: true});