-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathHideNon-EnglishUserstyles.user.js
More file actions
47 lines (42 loc) · 2.18 KB
/
HideNon-EnglishUserstyles.user.js
File metadata and controls
47 lines (42 loc) · 2.18 KB
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
// ==UserScript==
// @name Hide Non-English Userstyles on Userstyles.World
// @namespace nick2bad4u.github.io
// @version 1.10
// @description Hide userstyles containing non-English 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
// @homepage https://github.com/Nick2bad4u/UserStyles
// @downloadURL https://update.greasyfork.org/scripts/523266/Hide%20Non-English%20Userstyles%20on%20UserstylesWorld.user.js
// @updateURL https://update.greasyfork.org/scripts/523266/Hide%20Non-English%20Userstyles%20on%20UserstylesWorld.meta.js
// ==/UserScript==
(function () {
'use strict';
// Function to check if a string contains non-English characters
function containsNonEnglishCharacters(text) {
// Allow English letters, digits, spaces, and common punctuation
return /[^ -~\t\n\r]/.test(text);
// Matches characters outside printable ASCII, tab, newline, and carriage return
}
// Find all card elements on the page
document.querySelectorAll('.card').forEach((card) => {
// Get the text content from relevant child elements
const title = card.querySelector('.name')?.textContent.trim() || '';
// Get the title of the userstyle
const description = card.querySelector('.card-body')?.textContent.trim() || '';
// Get the description of the userstyle
const ariaLabel = card.querySelector('.card-header.thumbnail')?.getAttribute('aria-label') || '';
// Get the aria-label which may contain a description
// Log the content being checked
console.log(`Checking card: Title="${title}", Description="${description}", Aria-Label="${ariaLabel}"`);
// Check if any of these contain non-English characters
if (containsNonEnglishCharacters(title) || containsNonEnglishCharacters(description) || containsNonEnglishCharacters(ariaLabel)) {
// Hide the card if non-English characters are found
card.style.display = 'none';
console.log(`Hiding card: Title="${title}", Description="${description}", Aria-Label="${ariaLabel}"`);
}
});
})();