Ajoute la connexion automatique, un bouton télécharger à la recherche, et plus encore
当前为
// ==UserScript==
// @name YggTorrent amélioré
// @namespace https://openuserjs.org/users/clemente
// @match https://*.yggtorrent.si/*
// @version 1.4
// @author clemente
// @license MIT
// @description Ajoute la connexion automatique, un bouton télécharger à la recherche, et plus encore
// @icon https://www2.yggtorrent.si/favicon.ico
// @inject-into content
// @noframes
// @homepageURL https://openuserjs.org/scripts/clemente/YggTorrent_am%C3%A9lior%C3%A9
// @supportURL https://openuserjs.org/scripts/clemente/YggTorrent_am%C3%A9lior%C3%A9/issues
// ==/UserScript==
/* jshint esversion: 6 */
login();
addDownloadButtonToTorrents();
hideSidebar();
displayLargerNfo();
searchByLatestFirst();
fixFavicon();
function login() {
const loginButton = document.getElementById('register');
if (!loginButton) return; // If the user is already logged in, do nothing
let isLoginFormValid = true;
const loginForm = document.getElementById('user-login');
loginForm.querySelectorAll('input').forEach(input => {
isLoginFormValid = isLoginFormValid && input.checkValidity();
});
if (!isLoginFormValid) return; // If the form is not valid, then autocomplete is not active and the popup should not bother the user
loginButton.click();
loginForm.querySelector('button').click();
function closePopupIfDisplayed(mutations, observer) {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.classList.contains('alert-success')) {
document.querySelector('button.close').click();
observer.disconnect();
}
});
});
}
// Wait for the confirmation popup to appear then close it
const popupObserver = new MutationObserver(closePopupIfDisplayed);
popupObserver.observe(document.body, { childList: true });
}
function addDownloadButtonToTorrents() {
// For every torrent, add the download button
const torrents = document.querySelectorAll('.results table tbody tr');
torrents.forEach(torrent => {
const torrentId = torrent.querySelector('a[target]').target;
const downloadIcon = document.createElement('span');
downloadIcon.classList.add('ico_download');
const downloadButton = document.createElement('a');
downloadButton.href = `/engine/download_torrent?id=${torrentId}`;
downloadButton.append(downloadIcon);
downloadButton.style = 'float: left;';
const nameLink = torrent.querySelector('td:nth-child(3) a');
nameLink.parentNode.insertBefore(downloadButton, nameLink);
});
}
function hideSidebar() {
const sidebar = document.getElementById('cat');
if (sidebar.classList.contains('active')) {
sidebar.querySelector('.open').click();
}
}
function displayLargerNfo() {
const modal = document.getElementById('nfoModal');
if (!modal) return; // If there is no modal, the user is not on a torrent page and nothing should be done
const modalDialog = modal.querySelector('.modal-dialog');
modalDialog.classList.remove('modal-sm');
modalDialog.classList.add('modal-lg');
}
function searchByLatestFirst() {
const searchForm = document.querySelector('form.search');
const orderInput = document.createElement('input');
orderInput.name = 'order';
orderInput.value = 'desc';
orderInput.style = 'display: none';
const sortInput = document.createElement('input');
sortInput.name = 'sort';
sortInput.value = 'publish_date';
sortInput.style = 'display: none';
searchForm.append(orderInput);
searchForm.append(sortInput);
}
function fixFavicon() {
const favicon = document.querySelector('link[href="https://www.yggtorrent.pe/favicon.ico"]');
favicon.href = "https://www.yggtorrent.si/favicon.ico";
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址