// Добавляем шрифт Inter и Fira в документ
const linkInter = document.createElement('link');
linkInter.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap';
linkInter.rel = 'stylesheet';
document.head.appendChild(linkInter);
const linkFira = document.createElement('link');
linkFira.href = 'https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@600&display=swap';
linkFira.rel = 'stylesheet';
document.head.appendChild(linkFira);
// Добавляем CSS-правила для изменения шрифта на Inter и Fira
const style = document.createElement('style');
style.textContent = `
body {
font-family: 'Inter', sans-serif !important;
}
.use-fira {
font-family: 'Fira Sans Condensed', sans-serif !important;
}
`;
code
Assistant
Я запомнил ваш юзерскрипт. Если вам нужно будет напомнить его содержание или если у вас возникнут вопросы о его работе, просто дайте знать!
User
Дополни мой юзерскрипт, чтобы он заменял текст «CANCELLED» несмотря на то, написан он заглавными буквами или нет, на «отменена», а также, если «CANCELLED» заключена в круглые или квадратные скобки, и, будучи заключённой в скобки, написана без пробела после названия перед ней, то ставился пробел, в следующем коде:
Assistant
document.head.appendChild(style);
// Замена
function replaceText() {
// Лента
// Following
document.querySelectorAll('nav.-menu a span').forEach((element) => {
if (element.textContent.trim() === 'Following') {
element.textContent = 'Подписки';
}
});
// For You
document.querySelectorAll('nav.-menu a span').forEach((element) => {
if (element.textContent.trim() === 'For You') {
element.textContent = 'Для вас';
}
});
// Верхняя панель
// DISCOVER
document.querySelectorAll('nav#shell-top-nav a strong').forEach((element) => {
if (element.textContent.trim() === 'Discover') {
element.textContent = 'ОБЗОР';
}
});
// STORE
document.querySelectorAll('nav#shell-top-nav a strong').forEach((element) => {
if (element.textContent.trim() === 'Store') {
element.textContent = 'КАТАЛОГ';
}
});
// Поиск
document.querySelectorAll('label[for=“search-input-1”] span').forEach((element) => {
if (element.textContent.trim() === 'Search') {
element.textContent = 'Поиск';
}
});
document.querySelectorAll('input#search-input-1').forEach((element) => {
if (element.placeholder.trim() === 'Search') {
element.placeholder = 'Поиск';
}
});
// Get App
document.querySelectorAll('a').forEach((element) => {
if (element.textContent.trim() === 'Get App') {
element.textContent = 'Скачать приложение';
}
});
// Notifications
document.querySelectorAll('div.tooltip-inner').forEach((element) => {
if (element.textContent.trim() === 'Notifications') {
element.textContent = 'Уведомления';
}
});
// Friend Requests
document.querySelectorAll('div.tooltip-inner').forEach((element) => {
if (element.textContent.trim() === 'Friend Requests') {
element.textContent = 'Запросы в друзья';
}
});
// Подсказка зарядов
document.querySelectorAll('div.sticker-charge-tooltip > p > span, div.sticker-charge-tooltip > div > span').forEach((element) => {
const textContent = element.textContent.trim();
if (textContent === 'Complete daily quests to fill your charge orbs. Each day you miss a daily quest, your charge goes down.') {
element.textContent = 'Выполняйте ежедневные квесты, чтобы заряжать свои сферы. Каждый день, когда вы пропускаете квест, ваша энергия уменьшается.';
} else if (textContent === 'Once all your charge orbs are full, you can support your favorite Game Jolt Creators by giving them a charged sticker! Every charged sticker uses 2 charge orbs and puts 💰💰💰 in their IRL pockets.') {
element.textContent = 'Как только все сферы будут заряжены, вы сможете поддержать своих любимых создателей на Game Jolt, наклеив заряженную наклейку на их пост! Каждая заряженная наклейка расходует 2 заряженной сферы и ложит 💰💰💰 в их реальный кошелёк.';
}
});
// Daily Quests
document.querySelectorAll('h4').forEach((element) => {
if (element.textContent.trim() === 'Daily Quests') {
element.textContent = 'Ежедневные квесты';
}
});
// Learn more
document.querySelectorAll('span').forEach((element) => {
if (element.textContent.trim() === 'Learn more') {
element.textContent = 'Узнать больше';
}
});
// Заменяем «Charge» на «Заряд»
document.querySelectorAll('h4.-charge-text > span:first-child').forEach((element) => {
if (element.textContent.trim() === 'Charge') {
element.textContent = 'Заряд';
}
});
// Заменяем «h» на « ч.» в элементах с классом «text-muted»
document.querySelectorAll('span.text-muted').forEach((element) => {
if (element.textContent.includes('h')) {
element.textContent = element.textContent.replace(/(\d+)h/g, '$1 ч.');
}
});
// Квесты
// Ежедневный квест
document.querySelectorAll('div.text-center > div').forEach((element) => {
if (element.textContent.trim() === 'DAILY QUEST') {
element.textContent = 'ЕЖЕДНЕВНЫЙ КВЕСТ';
}
});
// Применение класса для использования шрифта Fira Sans
document.querySelectorAll('div[style*="Staatliches"]').forEach((element) => {
element.classList.add('use-fira');
});
document.querySelectorAll('div.text-center > div').forEach((element) => {
if (element.textContent.trim() === 'Cast your vote on a poll') {
element.textContent = 'ПРОГОЛОСУЙ В ОПРОСЕ';
}
});
document.querySelectorAll('div.content-viewer.quest-stage-description-content p span').forEach((element) => {
if (element.textContent.trim() === 'Your choices will affect the outcome, good or bad, so choose carefully!') {
element.textContent = 'Твои выборы повлияют на результат, будь он хорошим или плохим, так что выбирай внимательно!';
}
});
// Название вкладки
if (document.title.includes(' - ')) {
document.title = document.title.replace(' - ', ' — ');
}
if (document.title.includes('Share your creations')) {
document.title = document.title.replace('Share your creations', 'Делитесь своим творчеством');
}
if (document.title.includes('Fan art, videos, guides, polls and more')) {
document.title = document.title.replace('Fan art, videos, guides, polls and more', 'Фан-арт, видео, руководства, опросы и многое другое');
}
if (document.title.includes(' Community')) {
document.title = document.title.replace(' Community', ' (сообщество)');
}
if (document.title.includes('Fairy Kingdom of King Froggold II')) {
document.title = document.title.replace('Fairy Kingdom of King Froggold II', 'Сказочное королевство короля Фроггольда II');
}
if (document.title.includes('Pokémon')) {
document.title = document.title.replace('Pokémon', 'Покемон');
}
// Игры
// (Official)
document.querySelectorAll('div.-title[title*="(Official)"]').forEach((element) => {
if (element.title.includes('(Official)')) {
element.title = element.title.replace('(Official)', '(официальная)');
}
if (element.textContent.includes('(Official)')) {
element.textContent = element.textContent.replace('(Official)', '(официальная)');
}
});
// (CANCELLED)
document.querySelectorAll('div.-title[title*="(CANCELLED)"]').forEach((element) => {
if (element.title.includes('(CANCELLED)')) {
element.title = element.title.replace('(CANCELLED)', '(ОТМЕНЕНА)');
}
if (element.textContent.includes('(CANCELLED)')) {
element.textContent = element.textContent.replace('(CANCELLED)', '(ОТМЕНЕНА)');
}
});
// ELLIE'S
document.querySelectorAll('div.-title[title*="ELLIE\'S"]').forEach((element) => {
if (element.title.includes('ELLIE\'S')) {
element.title = element.title.replace('ELLIE\'S', 'ЭЛЛИС');
}
if (element.textContent.includes('ELLIE\'S')) {
element.textContent = element.textContent.replace('ELLIE\'S', 'ЭЛЛИС');
}
});
}
// Замена текста после загрузки DOM
document.addEventListener('DOMContentLoaded', replaceText);
// Оптимизация MutationObserver
let timeout;
const observer = new MutationObserver(() => {
clearTimeout(timeout);
timeout = setTimeout(replaceText, 0); // задержка
});
// Наблюдаем только за основными узлами, где могут происходить изменения
const targetNodes = [
document.querySelector('body'),
];
targetNodes.forEach(node => {
if (node) {
observer.observe(node, {
childList: true,
subtree: true
});
}
});
})();
Я внесу изменения в ваш юзерскрипт, чтобы он заменял текст «Cancelled» или «CANCELLED» (независимо от регистра) на «отменена», учитывая заключение в круглые или квадратные скобки. Также добавлю пробел перед скобками, если его нет. Вот как ваш обновленный скрипт будет выглядеть:
javascript
// ==UserScript==
// @name Русификатор Game Jolt
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Русифицирует Game Jolt
// @author Дефлекта
// @match https://gamejolt.com/*
// @match https://*.gamejolt.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Добавляем шрифт Inter и Fira в документ
const linkInter = document.createElement('link');
linkInter.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap';
linkInter.rel = 'stylesheet';
document.head.appendChild(linkInter);
const linkFira = document.createElement('link');
linkFira.href = 'https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@600&display=swap';
linkFira.rel = 'stylesheet';
document.head.appendChild(linkFira);
// Добавляем CSS-правила для изменения шрифта на Inter и Fira
const style = document.createElement('style');
style.textContent = `
body {
font-family: 'Inter', sans-serif !important;
}
.use-fira {
font-family: 'Fira Sans Condensed', sans-serif !important;
}
`;
document.head.appendChild(style);
// Замена
function replaceText() {
// Лента
// Following
document.querySelectorAll('nav.-menu a span').forEach((element) => {
if (element.textContent.trim() === 'Following') {
element.textContent = 'Подписки';
}
});
// For You
document.querySelectorAll('nav.-menu a span').forEach((element) => {
if (element.textContent.trim() === 'For You') {
element.textContent = 'Для вас';
}
});
// Верхняя панель
// DISCOVER
document.querySelectorAll('nav#shell-top-nav a strong').forEach((element) => {
if (element.textContent.trim() === 'Discover') {
element.textContent = 'ОБЗОР';
}
});
// STORE
document.querySelectorAll('nav#shell-top-nav a strong').forEach((element) => {
if (element.textContent.trim() === 'Store') {
element.textContent = 'КАТАЛОГ';
}
});
// Поиск
document.querySelectorAll('label[for=“search-input-1”] span').forEach((element) => {
if (element.textContent.trim() === 'Search') {
element.textContent = 'Поиск';
}
});
document.querySelectorAll('input#search-input-1').forEach((element) => {
if (element.placeholder.trim() === 'Search') {
element.placeholder = 'Поиск';
}
});
// Get App
document.querySelectorAll('a').forEach((element) => {
if (element.textContent.trim() === 'Get App') {
element.textContent = 'Скачать приложение';
}
});
// Notifications
document.querySelectorAll('div.tooltip-inner').forEach((element) => {
if (element.textContent.trim() === 'Notifications') {
element.textContent = 'Уведомления';
}
});
// Friend Requests
document.querySelectorAll('div.tooltip-inner').forEach((element) => {
if (element.textContent.trim() === 'Friend Requests') {
element.textContent = 'Запросы в друзья';
}
});
// Подсказка зарядов
document.querySelectorAll('div.sticker-charge-tooltip > p > span, div.sticker-charge-tooltip > div > span').forEach((element) => {
const textContent = element.textContent.trim();
if (textContent === 'Complete daily quests to fill your charge orbs. Each day you miss a daily quest, your charge goes down.') {
element.textContent = 'Выполняйте ежедневные квесты, чтобы заряжать свои сферы. Каждый день, когда вы пропускаете квест, ваша энергия уменьшается.';
} else if (textContent === 'Once all your charge orbs are full, you can support your favorite Game Jolt Creators by giving them a charged sticker! Every charged sticker uses 2 charge orbs and puts 💰💰💰 in their IRL pockets.') {
element.textContent = 'Как только все сферы будут заряжены, вы сможете поддержать своих любимых создателей на Game Jolt, наклеив заряженную наклейку на их пост! Каждая заряженная наклейка расходует 2 заряженной сферы и ложит 💰💰💰 в их реальный кошелёк.';
}
});
// Daily Quests
document.querySelectorAll('h4').forEach((element) => {
if (element.textContent.trim() === 'Daily Quests') {
element.textContent = 'Ежедневные квесты';
}
});
// Learn more
document.querySelectorAll('span').forEach((element) => {
if (element.textContent.trim() === 'Learn more') {
element.textContent = 'Узнать больше';
}
});
// Заменяем «Charge» на «Заряд»
document.querySelectorAll('h4.-charge-text > span:first-child').forEach((element) => {
if (element.textContent.trim() === 'Charge') {
element.textContent = 'Заряд';
}
});
// Заменяем «h» на « ч.» в элементах с классом «text-muted»
document.querySelectorAll('span.text-muted').forEach((element) => {
if (element.textContent.includes('h')) {
element.textContent = element.textContent.replace(/(\d+)h/g, '$1 ч.');
}
});
// Квесты
// Ежедневный квест
document.querySelectorAll('div.text-center > div').forEach((element) => {
if (element.textContent.trim() === 'DAILY QUEST') {
element.textContent = 'ЕЖЕДНЕВНЫЙ КВЕСТ';
}
});
// Применение класса для использования шрифта Fira Sans
document.querySelectorAll('div[style*="Staatliches"]').forEach((element) => {
element.classList.add('use-fira');
});
document.querySelectorAll('div.text-center > div').forEach((element) => {
if (element.textContent.trim() === 'Cast your vote on a poll') {
element.textContent = 'ПРОГОЛОСУЙ В ОПРОСЕ';
}
});
document.querySelectorAll('div.content-viewer.quest-stage-description-content p span').forEach((element) => {
if (element.textContent.trim() === 'Your choices will affect the outcome, good or bad, so choose carefully!') {
element.textContent = 'Твои выборы повлияют на результат, будь он хорошим или плохим, так что выбирай внимательно!';
}
});
// Название вкладки
if (document.title.includes(' - ')) {
document.title = document.title.replace(' - ', ' — ');
}
if (document.title.includes('Share your creations')) {
document.title = document.title.replace('Share your creations', 'Делитесь своим творчеством');
}
if (document.title.includes('Fan art, videos, guides, polls and more')) {
document.title = document.title.replace('Fan art, videos, guides, polls and more', 'Фан-арт, видео, руководства, опросы и многое другое');
}
if (document.title.includes(' Community')) {
document.title = document.title.replace(' Community', ' (сообщество)');
}
if (document.title.includes('Fairy Kingdom of King Froggold II')) {
document.title = document.title.replace('Fairy Kingdom of King Froggold II', 'Сказочное королевство короля Фроггольда II');
}
if (document.title.includes('Pokémon')) {
document.title = document.title.replace('Pokémon', 'Покемон');
}
// Игры
// (Official)
document.querySelectorAll('div.-title[title*="(Official)"]').forEach((element) => {
if (element.title.includes('(Official)')) {
element.title = element.title.replace('(Official)', '(официальная)');
}
if (element.textContent.includes('(Official)')) {
element.textContent = element.textContent.replace('(Official)', '(официальная)');
}
});
// (CANCELLED)
document.querySelectorAll('div.-title').forEach((element) => {
const regex = /(\[|\()?\s*CANCELLED\s*(\]|\))?/gi;
if (regex.test(element.title)) {
element.title = element.title.replace(regex, (match, p1, p2) => {
return `${p1 ? p1 : ''} отменена ${p2 ? p2 : ''}`;
}).replace(/ +/g, ' '); // Убрать лишние пробелы
}
if (regex.test(element.textContent)) {
element.textContent = element.textContent.replace(regex, (match, p1, p2) => {
return `${p1 ? p1 : ''} отменена ${p2 ? p2 : ''}`;
}).replace(/ +/g, ' '); // Убрать лишние пробелы
}
});
// ELLIE'S
document.querySelectorAll('div.-title[title*="ELLIE\'S"]').forEach((element) => {
if (element.title.includes('ELLIE\'S')) {
element.title = element.title.replace('ELLIE\'S', 'ЭЛЛИС');
}
if (element.textContent.includes('ELLIE\'S')) {
element.textContent = element.textContent.replace('ELLIE\'S', 'ЭЛЛИС');
}
});
}
// Замена текста после загрузки DOM
document.addEventListener('DOMContentLoaded', replaceText);
// Оптимизация MutationObserver
let timeout;
const observer = new MutationObserver(() => {
clearTimeout(timeout);
timeout = setTimeout(replaceText, 0); // задержка
});
// Наблюдаем только за основными узлами, где могут происходить изменения
const targetNodes = [
document.querySelector('body'),
];
targetNodes.forEach(node => {
if (node) {
observer.observe(node, {
childList: true,
subtree: true
});
}
});
})();
Теперь скрипт заменяет текст "Cancelled" или "CANCELLED" на "отменена", учитывая различные случаи включения в текст, включая круглые и квадратные скобки, а также добавляет пробел перед скобками, если его нет.