JetBrainsDirectLink

Direct download link buttons

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         JetBrainsDirectLink
// @namespace    https://www.jetbrains.com/
// @version      1.0
// @description  Direct download link buttons
// @author       You
// @match        https://www.jetbrains.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=jetbrains.com
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const path = window.location.pathname.split("/").filter(p => p.length > 0);
    if (path.length !== 2 || path[1] !== "download") return;

    const systems = ["windows", "macos", "linux"];

    let processDownloads = (downloads) => {
        const buttons = systems.reduce((map, name) => (map[name] = document.querySelector(`a[href*="download-thanks.html?platform=${name.substr(0, 3)}"]`), map), {});
        const elements = systems.reduce((map, name) => (map[name] = [document.createElement('br')], map), {});
        for (const target in downloads) {
            const system = systems.find(system => target.startsWith(system.substr(0, 3)));
            if (!system) continue;
            const button = document.createElement('a');
            button.setAttribute('href', downloads[target].link);
            button.text = `Download (${target})`;
            elements[system].push(button);
            elements[system].push(document.createElement('br'));
        }
        for (const system of systems) {
            const elementArray = elements[system];
            if (elementArray.length < 2) continue;
            let nextElement = buttons[system];
            while (!nextElement.parentNode.className.includes('__block'))
                nextElement = nextElement.parentNode;
            for (const element of elementArray) {
                nextElement.parentNode.insertBefore(element, nextElement);
                nextElement = element;
            }
        }
    }

    const openFn = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function (...args) {
        if (args.length > 1 && typeof args[1] === "string" &&
            args[1].startsWith("https://data.services.jetbrains.com/products/releases")) {
            XMLHttpRequest.prototype.open = openFn;
            fetch(args[1]).then(response => response.json().then(json => {
                const process = processDownloads;
                if (process != null) {
                    processDownloads = null;
                    process(json[Object.keys(json)[0]][0].downloads);
                }
            }));
        }
        return openFn.apply(this, args);
    }
})();