OGame: Localization

OGame: stores localization data on the client

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/4442/14625/OGame%3A%20Localization.js

  1. // ==UserScript==
  2. // @name OGame: Localization
  3. // @namespace https://gf.qytechs.cn/users/4668-black-cat
  4. // @description OGame: stores localization data on the client
  5. // @version 5.4
  6. // @creator Black Cat
  7. // @include http://*.ogame.gameforge.com/game/index.php?page=overview*
  8. // ==/UserScript==
  9.  
  10. var strFunc = (function(){
  11.  
  12. var ogTime = parseInt(document.querySelector("meta[name=ogame-timestamp]").getAttribute("content"));
  13. var xmlTime = parseInt(localStorage.getItem("localization.time") || "0");
  14.  
  15. var language = document.querySelector("meta[name=ogame-language]").getAttribute("content");
  16. var xmlLang = localStorage.getItem("localization.language");
  17. if (language != xmlLang) {
  18. xmlTime = 0;
  19. }
  20.  
  21. if (ogTime > xmlTime + 86400) {
  22. $.get(
  23. "/api/localization.xml?language="+language,
  24. function (xml) {
  25. var data = {};
  26. localStorage.setItem("localization.language", language);
  27. var loc = xml.childNodes[0];
  28. xmlTime = loc.getAttribute("timestamp");
  29. localStorage.setItem("localization.time", xmlTime);
  30. var parts = loc.childNodes;
  31. for (var i=0; i<parts.length; i++) {
  32. var tag = parts[i].tagName;
  33. data[tag] = {};
  34. var names = parts[i].childNodes;
  35. for (var j=0; j<names.length; j++) {
  36. var id = names[j].getAttribute("id");
  37. data[tag][id] = names[j].textContent;
  38. }
  39. }
  40. localStorage.setItem("localization.data", JSON.stringify(data));
  41. },
  42. "xml"
  43. );
  44. }
  45. }).toString();
  46.  
  47. if (!document.getElementById("localization_script")) {
  48. var script = document.createElement("script");
  49. script.id = "localization_script";
  50. script.setAttribute("type","text/javascript");
  51. script.text = "(" + strFunc + ")();";
  52. document.body.appendChild(script);
  53. }
  54.  

QingJ © 2025

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