from writer import process_file
import json
import sys
sys.dont_write_bytecode = True
# 读取 JSON 文件
def read_json(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
return json.load(file)
# 根据 relatedscripts 的 ID 找到对应的脚本
def find_script_by_greasyfork_id(scripts, greasyfork_id):
for script in scripts:
if str(script.get('GreasyFork')) == str(greasyfork_id):
return script
return None
# 生成描述信息,仅针对当前脚本的 relatedscripts
def generate_description(all_scripts, single_group=False):
related_scripts_map = {}
# single_group为True时,脚本归入“所有脚本”组,不进行分类
if single_group:
related_scripts_map['所有脚本'] = all_scripts
else:
for script in all_scripts:
relatedscript = script.get('relatedscripts')
if relatedscript not in related_scripts_map:
related_scripts_map[relatedscript] = []
related_scripts_map[relatedscript].append(script)
return related_scripts_map
# 生成 HTML 表格
def generate_html_table(scripts):
html_table = ''''''
for script in scripts:
full_path = script.get("backuppath") + "/" + script.get("path")
placeholder_image = "https://github.com/ChinaGodMan/UserScriptsHistory/raw/main/20241026_03380458.png"
img_tag = f'' if script.get("img") else f'
'
html_table += f'''
{img_tag}
''' return html_table # 生成分组后的HTML def generate_grouped_html(related_scripts_map, use_details=True, center=False): html_output = "" center_o = '' center_c = '' # 居中显示 if center: center_o = 'Greasemonkey /
自述文件 / 讨论