# -*- coding: utf-8 -*- import os import re def clean_and_save(path, content): content = content.replace('\r\n', '\n').replace('\r', '\n') lines = [line.rstrip() for line in content.split('\n')] result_lines = [] prev_empty = False for line in lines: if line == '': if not prev_empty: result_lines.append(line) prev_empty = True else: result_lines.append(line) prev_empty = False while result_lines and result_lines[-1] == '': result_lines.pop() text = '\r\n'.join(result_lines) + '\r\n' text = text.lstrip('\ufeff') with open(path, 'wb') as f: f.write(b'\xef\xbb\xbf' + text.encode('utf-8')) def update_top_index(): path = 'index.html' with open(path, 'rb') as f: c = f.read().decode('utf-8', errors='ignore') c = c.replace('\r\n', '\n') # ダンジョン・討滅戦・レイドのピックアップを増強 target = '開く ➜\n ' new_rows = '''開く ➜ クリスタルタワー:シルクスの塔 【アラルレ最頻出・メイン必須】 スキュラ(氷解凍・水たまり)、ガーディアン(跳躍台)、アモン(氷隠れ)、ザンデ(レビテト浮遊)。 開く ➜ クリスタルタワー:闇の世界 【全滅多発難関レイド】 アンラ・マンユ(死の視線・宣告解除)、ケルベロス(小人化胃袋突入・鎖繋ぎ)、暗闇の雲(雲踏み阻止)。 開く ➜ アルカディア:ライトヘビー級2〜4層 【黄金最新8人レイド】 LH2層ハニー・B・ラブリー(ハートスタック)、LH3層ブルートボンバー(ラリアット・爆弾)、LH4層ウィケッドサンダー(ウィッチハント・床破壊)。 開く ➜ 黄金主要討滅戦(ヴァリガルマンダ / ゾラージャ / エターナル・クイーン) 【Lv93・Lv99・Lv100ラスボス】 3属性天候変化、空間格子切断、仮想浮遊・重力反転、ドーン・エイジ完全攻略。 開く ➜ ''' if 'raids/syrcus_tower.html' not in c: if target in c: c = c.replace(target, new_rows) clean_and_save(path, c) print("Updated top index.html successfully") if __name__ == '__main__': update_top_index()