Greasyfork优化

①发布时间显示到秒②未汉化部分增加汉化

当前为 2020-09-23 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Greasyfork优化
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  ①发布时间显示到秒②未汉化部分增加汉化
// @author       You
// @match        https://greasyfork.org/*
// @require      https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $("time").each(function(){
        let datetime =  new Date($(this).attr("datetime"));
        let month = (datetime.getMonth()+1)<10 ? "0"+(datetime.getMonth()+1) : (datetime.getMonth()+1);
        let date = datetime.getDate()<10 ? "0"+datetime.getDate() : datetime.getDate();
        let hours = datetime.getHours()<10 ? "0"+datetime.getHours() : datetime.getHours();
        let minutes = datetime.getMinutes()<10 ? "0"+datetime.getMinutes() : datetime.getMinutes();
        let seconds = datetime.getSeconds()<10 ? "0"+datetime.getSeconds() : datetime.getSeconds();
        let posttime = datetime.getFullYear()+"-"+month+"-"+date+"\xa0\xa0"+hours+":"+minutes+":"+seconds;
        $(this).text(posttime);
    })

    var translate = new Map();
    translate.set("发布你编写的脚本","发布JavaScript脚本");
    translate.set("发布你编写的样式","发布CSS样式");
    translate.set("New script set","新建脚本收藏夹");
    translate.set("Greasy Fork can import scripts that already hosted elsewhere, for example in a version control system (like GitHub), your own server, or another user script hosting site.","Greasy Fork可以导入已经托管在其他地方的脚本,例如在版本控制系统(如GitHub)、或你自己的服务器、或其他用户脚本托管网站。");
    translate.set("Provide URLs to import from, separated by newlines. These should be URLs to the raw .user.js files.","在下方填写需要导入的脚本URL,每个URL独占一行。这些URL指向的必须是后缀名为.user.js的原始文本文件。");
    translate.set("After the initial import, the script(s) should be synced:","脚本导入后的同步设置:");
    translate.set("Automatically - periodically update it from the URL you provided","自动--定期同步导入的脚本");
    translate.set("Manually - only when you trigger it","手动--只有手动点击时才同步");
    translate.set("For scripts from source control, ensure that the URL you use refers to a branch and not a specific commit, otherwise it will never get updated. For example, ","对于来自源码控制系统的脚本,确保你使用的URL是指一个分支,而不是一个特定的提交,否则它将永远不会被更新。例如这个分支 ");
    translate.set(" rather than ",",而不是特定提交");
    translate.set("Scripts imported from GitHub, Bitbucket, or GitLab can also be set up to sync using a webhook. A webhook will make it so your scripts are immediately updated on Greasy Fork when you push to your repository. If you want to use a webhook but haven't set it up yet, do the import first, then ","从GitHub、Bitbucket、GitLab导入的脚本也可以通过webhook进行同步设置。当推送到你的版本库时,webhook会让你的脚本在Greasy Fork上立即更新。如果你想使用webhook,但还没有设置,请先导入脚本URL,然后");
    translate.set("set up the webhook after","设置 webhook");

    $("a").each(function(){
        $(this).text(translate.get($(this).text()));
    })

    if($(".radio-group").length>0)
    {
        $($(".radio-group").get(0).childNodes[0]).wrap("<span>");
        $(".radio-group span").text("After the initial import, the script(s) should be synced:");
    }


    $("p").each(function(){
        if($(this).text().indexOf("For scripts from source control, ensure that the URL you use refers to a branch") != -1)
        {
            $($(this).get(0).childNodes[0]).wrap("<span>");
        }
        if($(this).text().indexOf(" rather than ") != -1)
        {
            $($(this).get(0).childNodes[2]).wrap("<span>");
        }
        if($(this).text().indexOf("Scripts imported from GitHub, Bitbucket") != -1)
        {
            $($(this).get(0).childNodes[0]).wrap("<span>");
        }
        $(this).text(translate.get($(this).text()));
    })

    $('[data-disable-with="Import"]').val("导入");

    $("label, span").each(function(){
        $(this).text(translate.get($(this).text()));
    })
    
})();