Konadown

Alter Konachan download links so that they actually download the file instead of opening the file in chrome

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Konadown
// @namespace    https://konachan.com/
// @version      1.0
// @description  Alter Konachan download links so that they actually download the file instead of opening the file in chrome
// @author       kein
// @match        https://konachan.com/post/show/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

$(function() {
    'use strict';
    let name, fName, link, submit, pause, elementExists;

    // First link, the PNG
    elementExists = document.getElementsByClassName("original-file-unchanged");
    if (elementExists.length != 0) {
        link = $(".original-file-unchanged").attr("href");
        for (let i = 0; i < link.length; i++) {
            name += link[i];
            if (link[i] == "/") {
                name = "";
            }
        }
        submit = "";
        fName = "";
        for (let i = 0; i < name.length; i++) {
            if (pause > 0) {
                pause--;
                continue;
            }
            submit = name[i];
            if (submit == "%") {
                pause = 2;
                if (name[i]+name[i+1]+name[i+2] == "%21") {
                    submit = "!";
                } else {
                    submit = " ";
                }
            }
            fName += submit;
        }
        $(".original-file-unchanged").attr("download", fName);
    } else {
        console.warn("Unchanged file does not exist");
    }


    // Second link, the JPG
    elementExists = document.getElementsByClassName("original-file-changed");
    if (elementExists.length != 0) {
        link = $(".original-file-changed").attr("href");
        for (let i = 0; i < link.length; i++) {
            name += link[i];
            if (link[i] == "/") {
                name = "";
            }
        }
        submit = "";
        fName = "";
        for (let i = 0; i < name.length; i++) {
            if (pause > 0) {
                pause--;
                continue;
            }
            submit = name[i];
            if (submit == "%") {
                pause = 2;
                if (name[i]+name[i+1]+name[i+2] == "%21") {
                    submit = "!";
                } else {
                    submit = " ";
                }
            }
            fName += submit;
        }

        $(".original-file-changed").attr("download", fName);
    } else {
        console.warn("Changed file does not exist");
    }
})();