Greasy Fork Install Button at search

adds install button at search and at user pages.

当前为 2022-02-19 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

        // 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 > article > h2 > a, #browse-script-list > li > 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://greasyfork.org/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-css-available-as-js="true"] > 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://greasyfork.org/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>');
        });
    })();