Greasy Fork

Greasy Fork is available in English.

Macapp下载助手

为 macapp.so 增加一个下载按钮

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Macapp下载助手
// @namespace    http://nobelliu.github.io/
// @version      0.3
// @description  为 macapp.so 增加一个下载按钮
// @author       NobelLiu
// @match        http://www.macapp.so/*/
// @grant        none
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==
'use strict';
$(setTimeout(function () {
        if (document.getElementById("code")) {
            var download = document.getElementsByClassName("download")[0];
            var codeElement = document.getElementById("code");
            var dlButton = document.createElement('a');
            var code = document.body.innerHTML.match(/document.getElementById\("code"\).innerHTML="\w\w\w\w/).toString().match(/\w\w\w\w$/);
            dlButton.innerHTML = code;
            var href = "/go" + window.location.pathname + "#" +code;
            dlButton.setAttribute("href", href);
            dlButton.setAttribute("target", "_blank");
            dlButton.style.cssText = "color:gray;background-color:white;width:40px;height:24px;padding:2px 8px;border:1px solid #ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius:5px;";
            download.insertBefore(dlButton, codeElement);
            codeElement.removeAttribute("id")
        }
    }
    , 100));