Hide Chinese Userstyles on Userstyles.World

Hide userstyles containing Chinese characters on userstyles.world

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Hide Chinese Userstyles on Userstyles.World
// @namespace    typpi.online
// @version      1.6
// @description  Hide userstyles containing Chinese characters on userstyles.world
// @author       Nick2bad4u
// @license      UnLicense
// @match        https://userstyles.world/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=userstyles.world
// @grant        none
// @homepageURL  https://github.com/Nick2bad4u/UserStyles
// ==/UserScript==

(function () {
	'use strict';

	// Function to check if a string contains Chinese characters
	function containsChineseCharacters(text) {
		// Matches any Chinese characters in the range \u4E00-\u9FFF
		return /[\u4E00-\u9FFF]/.test(text);
	}

	// Function to process each card element
	function processCard(card) {
		// Get the text content from relevant child elements and trim whitespace
		const title = card.querySelector('.name')?.textContent.trim() || '';
		const description =
			card.querySelector('.card-body')?.textContent.trim() || '';
		const ariaLabel =
			card
				.querySelector('.card-header.thumbnail')
				?.getAttribute('aria-label')
				?.trim() || '';

		// Log the content being checked
		console.log(
			`Checking card: Title="${title}", Description="${description}", Aria-Label="${ariaLabel}"`,
		);

		// Check if any of these contain Chinese characters
		if (
			containsChineseCharacters(title) ||
			containsChineseCharacters(description) ||
			containsChineseCharacters(ariaLabel)
		) {
			// Hide the card if Chinese characters are found
			card.style.display = 'none';
			console.log(
				`Hiding card: Title="${title}", Description="${description}", Aria-Label="${ariaLabel}"`,
			);
		}
	}

	// Find all card elements on the page and process each
	document.querySelectorAll('.card').forEach(processCard);
})();