Linguee show date v0.6

Shows the date of the translated source.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Linguee show date v0.6
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  Shows the date of the translated source.
// @author       Emilis
// @match        www.linguee.com/*
// @require      https://code.jquery.com/jquery-1.12.0.min.js
// ==/UserScript==
$(document).ready(function() {
    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
    addGlobalStyle('.date{font-size:11px;color:#777;float:right;margin:0px;padding-right:20px;}.datered{font-size:11px;color:orange;float:right;margin:0px;padding-right:20px;}.source_url_spacer{display:none;}.source_url{position:relative;width:100%;display:inline-block;bottom:auto;right:auto;}.source_url a{float:left;}');
    source_url_get = $(".source_url > a");var link_get;var i_index_i;var matchResult;var date4;var link4_8check = /(19|20)+[0-9]+[0-9]/;var link2check = /(9|0|1|2)+[0-9]/;
    for (i_index_i = 0; i_index_i < source_url_get.length; ++i_index_i) {
        link_get = source_url_get.eq(i_index_i).attr('href');
        if(link4_8check.test(link_get)){
            if(link_get.match(link4_8check)[0].length == 4){
                $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: " + link_get.match(link4_8check)[0] + "</p>");
            }else if(link_get.match(link4_8check)[0].length == 8){
                $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: " + link_get.match(link4_8check)[0].slice(0,4)+" "+link_get.match(link4_8check)[0].slice(4,6)+" "+link_get.match(link4_8check)[0].slice(6,8) + "</p>");
            }else{
                console.log("Invalid date lenght");
            }
        }else if(link2check.test(link_get)){
            if(link_get.match(link2check)[0].length == 2 && link_get.match(link2check)[0] >= 40){
                $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: "+"19"+ link_get.match(link2check)[0] + "</p>");
            }else if(link_get.match(link2check)[0].length == 2 && link_get.match(link2check)[0] < 40){
                $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: "+"20"+ link_get.match(link2check)[0] + "</p>");
            }        
        }else{
            $(".source_url > a").eq(i_index_i).after("<p class='datered'>Date not found.</p>");
        }
    }    
});