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

如何通过Chrome控制台批量修改指定类的网页价格数值

批量上调指定类机票价格的Chrome控制台JS代码

实现代码

打开Chrome控制台(快捷键F12或Ctrl+Shift+I),粘贴以下代码执行即可:

// 获取所有目标价格元素
const priceElements = document.querySelectorAll('.css-901oao.r-t1w4ow.r-ubezar.r-1kfrs79.r-135wba7.r-fdjqy7');

// 遍历每个价格元素处理
priceElements.forEach(el => {
  // 提取Rp后的价格文本
  const priceText = el.firstChild.textContent.trim().replace('Rp ', '');
  // 移除千分位分隔符并转为数字
  const originalPrice = parseInt(priceText.replace(/\./g, ''), 10);
  // 计算上调50000后的价格
  const newPrice = originalPrice + 50000;
  // 重新格式化为带千分位的印尼盾格式
  const formattedPrice = newPrice.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
  // 更新价格文本(保留原有的/org标签)
  el.firstChild.textContent = `Rp ${formattedPrice}`;
});

代码说明

  • 用document.querySelectorAll精准选中所有目标类的价格容器
  • 通过firstChild单独处理价格文本节点,避免修改后面的/org span元素
  • 先把带千分位的价格转成纯数字计算,再重新格式化回印尼盾的显示格式
  • 全程保留页面原有元素结构,只修改价格数值

效果验证

执行后页面价格会按要求更新,例如:

  • Rp 1.430.800/org → Rp 1.450.800/org
  • Rp 1.551.165/org → Rp 1.571.165/org
  • Rp 1.612.170/org → Rp 1.632.170/org
  • Rp 1.691.445/org → Rp 1.711.445/org

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 11:13:19