Greasy Fork Install Button at search

adds install button at search and at user pages.

От 22.02.2022. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name Greasy Fork Install Button at search
// @namespace -
// @version 0.4
// @description adds install button at search and at user pages.
// @author NotYou
// @include *sleazyfork.org/*
// @include *greatest.deepsurf.us/*
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @grant none
// @license GPL-3.0-or-later
// ==/UserScript==

/*

﹀ Change Log ﹀

0.4 Version:
- Removed HTTP support
- Added libraries support

0.3 Version:
- SleazyFork support
- HTTP support

0.2 Version:
- Better css styles identifying

*/

$(document).ready(
    function() {
        'use strict';

        var domain = location.host

        // STYLES
        $('head').append('<style> .custom-install-link-parent{text-decoration: none !important;}.custom-install-link-parent > *{transform: scale(0.7);}.custom-install-link{margin-right: -15px !important;margin-left: -6px !important;}.custom-install-style-link{margin-left: -14px !important;margin-right: -26px !important;}</style>');

        // USER SCRIPT
        $('#user-script-list > li[data-script-type="public"] > article > h2 > a, #browse-script-list > li[data-script-type="public"] > article > h2 > a').each(function() {
            let scriptId = $(this).parent().parent().parent().data('script-id');
            let scriptName = $(this).parent().parent().parent().data('script-name');
            $(this).append('<span data-install-format="js" data-script-id="'+ scriptId +'" data-script-name="' + scriptName + '"><a href="https://' + domain + '/scripts/' + scriptId + '/code/' + scriptName + '.user.js" class="custom-install-link-parent"><span class="install-link custom-install-link">Install</span></a><span>');
        });

        // USER STYLE
        $('#user-script-list > li[data-script-language="css"] > article > h2 > a, #browse-script-list > li[data-script-language="css"] > article > h2 > a').each(function() {
            let scriptId = $(this).parent().parent().parent().data('script-id');
            let scriptName = $(this).parent().parent().parent().data('script-name');
            $(this).append('<span data-install-format="css" data-script-id="'+ scriptId +'" data-script-name="' + scriptName + '"><a target="_blank" href="https://' + domain + '/scripts/' + scriptId + '/code/' + scriptName + '.user.css" class="custom-install-link-parent"><span class="install-link custom-install-style-link">Install as style</span></a><span>');
        });

        // LIBRARIES
        $('#user-script-list > li[data-script-type="library"] > article > h2 > a, #browse-script-list > li[data-script-type="library"] > article > h2 > a').each(function() {
            let scriptId = $(this).parent().parent().parent().data('script-id');
            let scriptName = $(this).parent().parent().parent().data('script-name');
            let scriptNameFinal = scriptName.replace(/\s/g, "-");
            $(this).append('<span data-install-format="js" data-script-id="'+ scriptId +'" data-script-name="' + scriptName + '"><a href=javascript:void(0) onclick=navigator.clipboard.writeText("https://' + domain + '/scripts/' + scriptId + '/code/' + scriptNameFinal + '.js") class="custom-install-link-parent"><span class="install-link custom-install-link">Copy URL</span></a><span>');
        });
    });