You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过外部JavaScript修改white-label.js中的配置参数?

Hey there! No worries about your English at all—let’s walk through exactly how to do this step by step.

Step 1: Set up your main FTP file

First, save your core code to FTP as white-label.js. Important note: you don’t need the surrounding <script> tags in the .js file—just the pure JavaScript. Here’s what the file content should look like:

var CT = {
  ABE: {
    Settings: {
      clientID: 378455,
      language: 'IT',
      age: 40,
      residenceID: 'IE',
      pickupID: 11,
      leadDays: 7,
      durationDays: 7,
    }
  }
};
Step 2: Modify parameters without editing the main file

Since the CT.ABE.Settings object is defined in the global scope, we can override its values after loading the main file. There are two straightforward ways to do this:

Option 1: Directly overwrite global variables (simplest)

Just load the main script first, then run a small script to update the specific parameters you want:

<!-- Load the main white-label script from your FTP -->
<script src="your-ftp-url/white-label.js"></script>

<!-- Now modify the parameters -->
<script type="text/javascript">
// Update clientID to your new value
CT.ABE.Settings.clientID = 909345;
// Change language to English (or any other code)
CT.ABE.Settings.language = 'en';
// Feel free to update other parameters too
CT.ABE.Settings.age = 35;
CT.ABE.Settings.residenceID = 'US';
</script>

How this works: The main script creates the global CT object first. Our follow-up script directly accesses this object and overwrites its properties—any code that uses CT.ABE.Settings afterward will use the updated values.

Option 2: Use a data attribute for configuration (cleaner, more flexible)

This is similar to the example you shared, where you store custom config in an HTML element. It’s great if you want to keep config separate from code, or need to adjust settings dynamically:

<!-- First, define your custom configuration in a data attribute -->
<div data-white-label-config>
{
  "clientID": 909345,
  "language": "en",
  "age": 35,
  "residenceID": "US"
}
</div>

<!-- Load the main white-label script -->
<script src="your-ftp-url/white-label.js"></script>

<!-- Add a script to read the config and merge it with the main settings -->
<script type="text/javascript">
// Grab the config element
const configElement = document.querySelector('[data-white-label-config]');
if (configElement) {
  try {
    // Parse the JSON config from the element
    const customConfig = JSON.parse(configElement.textContent.trim());
    // Merge the custom config into the main Settings object (overwriting existing values)
    Object.assign(CT.ABE.Settings, customConfig);
  } catch (error) {
    console.error('Oops, there was an error parsing the config:', error);
  }
}
</script>

How this works: We store our custom settings as JSON in an HTML element. The script reads this JSON, parses it into a JavaScript object, then uses Object.assign() to merge the custom values into the main CT.ABE.Settings object—overwriting any properties that match.

Quick reminders:

  • Always load your modification script after the main white-label.js—otherwise, the CT object won’t exist yet, and you’ll get an error.
  • Double-check that your white-label.js file doesn’t have <script> tags inside it—those are only for HTML files, not pure JS files.

内容的提问来源于stack exchange,提问作者Andrea Guerra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:24:51