Linguee show date v0.6

Shows the date of the translated source.

  1. // ==UserScript==
  2. // @name Linguee show date v0.6
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description Shows the date of the translated source.
  6. // @author Emilis
  7. // @match www.linguee.com/*
  8. // @require https://code.jquery.com/jquery-1.12.0.min.js
  9. // ==/UserScript==
  10. $(document).ready(function() {
  11. function addGlobalStyle(css) {
  12. var head, style;
  13. head = document.getElementsByTagName('head')[0];
  14. if (!head) { return; }
  15. style = document.createElement('style');
  16. style.type = 'text/css';
  17. style.innerHTML = css;
  18. head.appendChild(style);
  19. }
  20. 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;}');
  21. 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]/;
  22. for (i_index_i = 0; i_index_i < source_url_get.length; ++i_index_i) {
  23. link_get = source_url_get.eq(i_index_i).attr('href');
  24. if(link4_8check.test(link_get)){
  25. if(link_get.match(link4_8check)[0].length == 4){
  26. $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: " + link_get.match(link4_8check)[0] + "</p>");
  27. }else if(link_get.match(link4_8check)[0].length == 8){
  28. $(".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>");
  29. }else{
  30. console.log("Invalid date lenght");
  31. }
  32. }else if(link2check.test(link_get)){
  33. if(link_get.match(link2check)[0].length == 2 && link_get.match(link2check)[0] >= 40){
  34. $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: "+"19"+ link_get.match(link2check)[0] + "</p>");
  35. }else if(link_get.match(link2check)[0].length == 2 && link_get.match(link2check)[0] < 40){
  36. $(".source_url > a").eq(i_index_i).after("<p class='date'>Date: "+"20"+ link_get.match(link2check)[0] + "</p>");
  37. }
  38. }else{
  39. $(".source_url > a").eq(i_index_i).after("<p class='datered'>Date not found.</p>");
  40. }
  41. }
  42. });

QingJ © 2025

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