-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHideChineseUserstyles.user.js
58 lines (52 loc) · 2.03 KB
/
HideChineseUserstyles.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name Hide Chinese Userstyles on Userstyles.World
// @namespace typpi.online
// @version 1.5
// @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://userstyles.github.typpi.online
// @downloadURL https://update.greasyfork.org/scripts/523264/Hide%20Chinese%20Userstyles%20on%20UserstylesWorld.user.js
// @updateURL https://update.greasyfork.org/scripts/523264/Hide%20Chinese%20Userstyles%20on%20UserstylesWorld.meta.js
// ==/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);
})();