# -*- coding: utf-8 -*-
import re, io, sys, os, shutil
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
src = 'index_main.html'
shutil.copy(src, 'index_main.html.bak_r321c')
h = open(src, encoding='utf-8').read()

v0 = h.index("const VERIFIED_DETAILS=")
v1 = h.index(");", v0)
vdseg = h[v0:v1]
target = '"details/ut-c4f263b.html"'
print('VD 段内出现次数:', vdseg.count(target))
# 删除元素连同前导逗号
newvd = vdseg.replace(',' + target, '')
print('删除后目标残留:', target in newvd)
h2 = h[:v0] + newvd + h[v1:]

vd = re.findall(r'"([^"]+)"', newvd)
print('VD 集合数:', len(vd))
open(src, 'w', encoding='utf-8').write(h2)
print('written, bytes=', os.path.getsize(src))
