wimbledon.com event filter for men

shows only the men's singles match info for live and upcoming events.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         wimbledon.com event filter for men
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  shows only the men's singles match info for live and upcoming events.
// @author       big-guy
// @match        https://www.wimbledon.com/en_GB/scores/*
// @icon         https://www.google.com/s2/favicons?domain=wimbledon.com
// @grant        none
// ==/UserScript==


//press f or click empty space to filter only mens singles matches.

function filterw(){
  console.log('filtering for men only');
  var matches = [];
  document.querySelectorAll('.match').forEach(function(post) {
    var isMen = (post.getElementsByClassName('event')[0].innerText.toLowerCase().search("gentlemen's singles") >= 0) || false;
    if (!isMen){
      post.remove()
    }
  });
  document.querySelectorAll('.match-box-container').forEach(function(post) {
    var isMen = (post.getElementsByClassName('event-type')[0].innerText.toLowerCase().search("gentlemen's singles") >= 0) || false;
    if (!isMen){
      post.remove()
    }
  });
  document.querySelectorAll('.match-information span').forEach(function(post) {
    post.querySelectorAll('.player-info .match-type-status .match-type').forEach(function(subpost) {
      var isMen = (subpost.innerText.toLowerCase().search("gentlemen's singles") >= 0);
      if (isMen==false){
        post.remove()
      }
    });
  });
}

var a = document.createElement('a');
    a.id = "mybutt";
    a.class = 'togg';
    a.href = 'javascript:void(0)';
    a.innerText = "[FILTER FOR MEN]";
    a.onclick = filterw;

function append(){
  document.getElementsByClassName('live-status') ? document.getElementsByClassName('live-status')[0].prepend(a) : alert('click anywhere on the page to show filter button at top left');//live-status

}
console.log('removing womens press f');
document.addEventListener('load',append());
document.onclick = function () {
  filterw()
    document.getElementsByClassName('jsx-parser') && !document.getElementById('mybutt') ? document.getElementsByClassName('jsx-parser')[0].append(a) : null;
    document.getElementsByClassName('sidepanel-content-scores') && !document.getElementById('mybutt')  ? document.getElementsByClassName('sidepanel-content-scores')[0].prepend(a) : null;
};

document.addEventListener('keydown', function(event) {
  if (event.code == 'KeyF'){
    console.log('got keypress');
    filterw();
  }
});