### Configure Theme, Language, and Favicon (JavaScript) Source: https://developer-food.99app.com/openapi/index This script dynamically configures the website's theme (based on host), language (based on URL path), and favicon. It checks for the presence of a favicon link, creates one if missing, and sets the appropriate icon and rel attribute based on whether the host contains '99app'. It also sets the document title based on the host. ```javascript // 设置主题 let host = location.host let is99 = host.indexOf('99app') !== -1; // 设置语言 let lang = location.pathname.split('/')[1] if(lang){ document.documentElement.setAttribute('data-lang', lang); } // 设置favicon let link = document.querySelector("link[rel*='icon']") const haveLink = link !== null if (!haveLink) { link = document.createElement('link'); } link.type = 'image/x-icon'; if(is99){ link.rel = 'icon'; link.href = 'https://img0.didiglobal.com/static/gstar/img/zaKalGdBvJ1744205176096.png'; }else{ link.rel = 'shortcut icon'; link.href = 'https://website.didiglobal.com/DDlogo.ico'; } if (!haveLink) { document.getElementsByTagName('head')[0].appendChild(link); } // 设置标题 if(is99){ document.title = '99Food · Open platform' }else{ document.title = 'DiDi Food · Open platform' } ``` -------------------------------- ### Load Internationalization (i18n) Copywriter (JavaScript) Source: https://developer-food.99app.com/openapi/index This script handles the loading of internationalization (i18n) copywriter data. It first checks local storage for existing data and version information. If the data is missing, outdated, or the version doesn't match, it dynamically loads the appropriate language-specific JavaScript file. It also includes error handling for local storage operations and script loading. ```javascript "use strict"; try { (function () { if (window.__PRERENDER_INJECTED && window.__PRERENDER_INJECTED.isPreRenderer === true) return; var loadURL = "//img0.didiglobal.com/static/copywriter_h5/H5-soda-fe-soda-b-openapi-i18n/src/i18n/all.js"; var loadScript = function loadScript(url, onload, onerror) { var JSElement = document.createElement("script"); JSElement.src = url; JSElement.onload = onload; JSElement.onerror = onerror; document.head.appendChild(JSElement); }; var loadCopywriter = function loadCopywriter(url) { loadScript(url, function () { window.i18nPluginH5DiffCopywriterLoaded = "success"; try { localStorage.setItem("i18nPluginH5DiffCopywriter/H5-soda-fe-soda-b-openapi-i18n/src/i18n", JSON.stringify(window.i18nPluginH5DiffCopywriter)); } catch (e) { window.i18nPluginH5DiffCopywriterLoaded = "Copywriter localStorage failed"; } }, function (e) { window.i18nPluginH5DiffCopywriterLoaded = "Copywriter load failed"; }); }; window.i18nPluginH5DiffCopywriter = JSON.parse(localStorage.getItem("i18nPluginH5DiffCopywriter/H5-soda-fe-soda-b-openapi-i18n/src/i18n") || null); var localVersion = localStorage.getItem("i18nPluginH5DiffCopywriterVersion/H5-soda-fe-soda-b-openapi-i18n/src/i18n"); var langMatch = location.search.match(/lang=(((?!\&).)+)/); var lang = langMatch ? langMatch[1].replace('-', '_').toLowerCase() : "full"; try { lang = location.href.split('/')[3].replace('-', '_').toLowerCase() } catch (e) {}; loadScript(loadURL.replace("/all.js", "/conf.js"), function () { try { localStorage.setItem("i18nPluginH5DiffCopywriterVersion/H5-soda-fe-soda-b-openapi-i18n/src/i18n", window.i18nPluginH5DiffCopywriterConf[lang]); } catch (e) { window.i18nPluginH5DiffCopywriterLoaded = "CopywriterVersion localStorage failed"; } if (!window.i18nPluginH5DiffCopywriter || lang && !window.i18nPluginH5DiffCopywriter[lang] || localVersion !== window.i18nPluginH5DiffCopywriterConf[lang]) { loadCopywriter(loadURL.replace("/all.js", "/".concat(lang, ".js"))); } else { window.i18nPluginH5DiffCopywriterLoaded = "success"; } }, function () { loadCopywriter(loadURL.replace("/all.js", "/".concat(lang, ".js"))); }); })(); } catch (e) { window.i18nPluginH5DiffCopywriterLoaded = "js error"; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.