wimbledon.com event filter for men

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();
  }
});