E621 辅助翻译

目前仅支持汉化 E621 的标签,且字典尚不完善

  1. // ==UserScript==
  2. // @name E621 辅助翻译
  3. // @name:en-US E621 translator for Chinese
  4. // @namespace https://greasyfork.org/users/159546
  5. // @version 1.0.2
  6. // @description 目前仅支持汉化 E621 的标签,且字典尚不完善
  7. // @description:en-US E621 tags translate to Chinese
  8. // @author LEORChn
  9. // @match https://e621.net/posts*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=e621.net
  11. // @grant none
  12. // @run-at document-start
  13. // @license MIT
  14. // ==/UserScript==
  15. initEZLib();
  16.  
  17. var tagsRaw = `
  18. // 所有行都会无视前空格。所有原文都无视大小写。注释必须写在双斜杠后。
  19. // Copyrights // 版权
  20. nintendo, pokemon: 任天堂,宝可梦
  21. mythology, european mythology, greek mythology: 神话,欧洲神话,希腊神话
  22. asian mythology, east asian mythology, chinese mythology: 亚洲神话,东亚神话,中国神话
  23.  
  24. // Species // 种族
  25. pokemon (species), generation 1 pokemon: 口袋妖怪,第一代口袋妖怪
  26. mammal: 哺乳动物
  27. canine, canid, canis, wolf: 高智力犬类,犬科,犬属,狼 // FIXME: 暂时被搞晕了
  28. leporid, lagomorph, rabbit: 兔类,兔形目,兔子
  29.  
  30. // General // 一般
  31. feral, anthro: 野生形态,直立形态
  32. clothed, clothing: 着装得体的,着装的 // FIXME: 这两者的区别有待修改
  33. asian clothing, east asian clothing, chinese clothing: 亚洲服饰,东亚服饰,中国服饰
  34. armor: 防具
  35. chinese, hanfu, chinese dress: 中国的,汉服,旗袍?
  36. moon, full moon: 月亮,满月
  37. video games: 电子游戏
  38. simple background: 简单的背景
  39.  
  40. solo, duo, trio: 角色数量 单个,角色数量 两个,角色数量 三个
  41. group, large group: 团体,三个角色以上大团体
  42. unseen character: 涉及到图像外的角色
  43. male, female, male/female, male/male, female/female: 雄性,雌性,雄性和雌性,雄性和雄性,雌性和雌性
  44. facial hair, beard, hair: 面部毛发,胡子,头发和胡子等毛发
  45. feathers, wings: 羽毛,翅膀
  46. smile, blush: 微笑,脸红
  47. nude, sex, erection, penetration, cum: 裸体,性交,勃起,中出,射精
  48. bodily fluids, genital fluids: 体液,生殖液
  49. genitals, penis, balls, breasts, nipples: 生殖器,阴茎,睾丸,乳房,乳头
  50.  
  51. // Meta // 图像元数据
  52. thumbnail, low res: 缩略图,低分辨率
  53. hi res, absurd res, superabsurd res: 高分辨率,超高分辨率,顶级分辨率
  54. wallpaper: 可用于壁纸的分辨率
  55. text, english text: 有文本的,有英语文本
  56. `;
  57. var tags = {};
  58. var tagsFlatArray = tagsRaw.split('\n').map(function(lineText){
  59. if(!lineText.trim().length) return; // 去除纯空行
  60. if(lineText.trim().startsWith('//')) return; // 去除注释行
  61. var kv = lineText.split('//')[0].split(/[::]/); // 支持行内注释,
  62. var keys = kv[0].split(/[,,]/),
  63. values = kv[1].split(/[,,]/);
  64. if(keys.length != values.length) alert('发现这一行没有对齐:\n' + lineText);
  65. return keys.map(function(e, i){
  66. try{
  67. return [e.trim().toLowerCase(), values[i].trim()];
  68. }catch(err){
  69. if(keys.length <= values.length) alert('在解析这一行时发生错误:\n' + lineText);
  70. // 如果key数量大于value数量,那么前面的没有对齐信息就已经讲过了
  71. }
  72. });
  73. }).filter(function(e){ return e; }).flat();
  74. tagsFlatArray.foreach(function(e, i){
  75. tags[e[0]] = e[1];
  76. });
  77. setInterval(function(){
  78. $$('.search-tag').foreach(e=>{
  79. var origin = e.innerText;
  80. if(!(origin in tags)) return;
  81. e.innerText = tags[origin];
  82. });
  83. }, 1000);
  84.  
  85.  
  86.  
  87. function $$(e){ return document.querySelectorAll(e); }
  88. function initEZLib(){
  89. Array.prototype.foreach =
  90. NodeList.prototype.foreach = function(func){
  91. if(!(func instanceof Function)) return;
  92. for(var i=0; i < this.length; i++) try{
  93. if(func(this[i], i, this)) return true;
  94. }catch(e){
  95. console.warn(e);
  96. }
  97. }
  98. }