Factorio Free Mods Downloader from re146.dev

Changes all the links for download on https://mods.factorio.com with force download links. Dont Forget say Thanks to re146.dev

当前为 2024-11-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Factorio Free Mods Downloader from re146.dev
// @namespace    https://re146.dev/
// @version      1.5
// @description  Changes all the links for download on https://mods.factorio.com with force download links. Dont Forget say Thanks to re146.dev
// @author       Devito
// @match        https://mods.factorio.com/mod/*
// @match        https://mods.factorio.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mods.factorio.com
// @license      MIT
// ==/UserScript==



function FactorioFreeModsDownloader() {
    'use strict';
    //Инициализируем переменную с названием мода
    var ModNameGlobal = 0;
    // Проверяем, подходит ли ссылка под условие
    if (/^https:\/\/mods\.factorio\.com\/mod\/([^\/]+)/.test(location.href)) {
        // Если подходит, извлекаем имя мода
        ModNameGlobal = location.href.match(/^https:\/\/mods\.factorio\.com\/mod\/([^\/]+)/)[1];
        // Убираем все, что идет после символа вопросительного знака (если он есть)
        ModNameGlobal = ModNameGlobal.split('?')[0];
    }
    /*
        const elems = document.querySelectorAll(".button-green");
        [].forEach.call(elems, function(el) {
        el.classList.remove("disabled");
    });
    */
    let buttons = Array.from(document.getElementsByClassName('button-green'));
    for (const button of buttons) {
        let modName = ModNameGlobal
        const buttonText = button.innerText.trim().toLowerCase();
        const buttonParentType = button.parentElement.tagName.toLowerCase()
        // Если текст кнопки 'download'
        if (buttonText === 'download') {
            button.classList.remove('disabled');
            // Если модуль еще не задан, извлекаем название мода
            if (!modName) {
                const tempname = button.closest('.panel-inset-lighter')
                    .querySelector('.result-field')
                    .getAttribute('href');
                modName = tempname.split('?')[0].split('/mod/')[1];
            }
            // Определяем базовую логику для обновления кнопки
            const updateButton = (href) => {
                button.innerText = 'DownLoad';
                button.setAttribute('target', '_blank');
                button.setAttribute('href', href);
            };
            // Устанавливаем ссылки и другие атрибуты в зависимости от родительского элемента
            if (buttonParentType === 'div') {
                const href = `https://re146.dev/factorio/mods/ru#https://mods.factorio.com/mod/${modName}`;
                updateButton(href);
            } else if (buttonParentType === 'td') {
                const version = button.parentElement.parentElement.children[0].innerText;
                const href = `https://mods-storage.re146.dev/${modName}/${version}.zip`;
                updateButton(href);
            }
        }
    }
}


FactorioFreeModsDownloader();

// Выбираем элемент для наблюдения
const indicator = document.getElementById('indicator');
const observer = new MutationObserver((mutationsList, observer) => {
    // Здесь вы можете проверять, что именно изменилось на странице
    mutationsList.forEach(mutation => {
        if (mutation.type === 'attributes') {
            // Если структура DOM изменилась (например, добавление новых элементов)
            FactorioFreeModsDownloader();
        }
    });
});
// Определяем параметры для наблюдения
const config = {
    attributes: true, // Отслеживание изменений атрибутов (опционально)
};
// Начинаем наблюдение за indicator или любым другим элементом, который вам нужен
observer.observe(indicator, config);