Greasyfork优化

①评论时间显示到分钟②未汉化部分增加汉化

目前為 2020-09-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Greasyfork优化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  ①评论时间显示到分钟②未汉化部分增加汉化
// @author       You
// @match        https://gf.qytechs.cn/*
// @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()));
    })
    
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址