状态重置(防呆)修复
This commit is contained in:
+60
-11
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Mysteel 钢铁价格提取器
|
// @name Mysteel 钢铁价格提取器
|
||||||
// @namespace solitude@hraulein.com
|
// @namespace solitude@hraulein.com
|
||||||
// @version 0.8.5
|
// @version 0.8.8
|
||||||
// @description 实现列表页与详情页的抓取逻辑,统一透视表导出csv/xlsx,支持多维筛选及本地缓存
|
// @description 实现列表页与详情页的抓取逻辑,统一透视表导出csv/xlsx,支持多维筛选及本地缓存
|
||||||
// @author ali
|
// @author ali
|
||||||
// @match *://*.mysteel.com/market/*
|
// @match *://*.mysteel.com/market/*
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
// 读取本地缓存的筛选条件
|
// 读取本地缓存的筛选条件
|
||||||
function loadSavedFilters() {
|
function loadSavedFilters() {
|
||||||
const defaultFilters = { names: [], specs: [], materials: [], excludes: '', exportFormat: 'csv', exportFilename: '钢材透视价格表', debugMode: false, devMode: false };
|
const defaultFilters = { names: [], specs: [], materials: [], excludes: '', exportFormat: 'xlsx', exportFilename: '钢材透视价格表', debugMode: false, devMode: false };
|
||||||
const saved = localStorage.getItem('mysteel_filters');
|
const saved = localStorage.getItem('mysteel_filters');
|
||||||
if (saved) {
|
if (saved) {
|
||||||
try {
|
try {
|
||||||
@@ -188,11 +188,11 @@
|
|||||||
#mysteel-filter-panel::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 4px; }
|
#mysteel-filter-panel::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 4px; }
|
||||||
#mysteel-filter-panel::-webkit-scrollbar-track { background: transparent; }
|
#mysteel-filter-panel::-webkit-scrollbar-track { background: transparent; }
|
||||||
</style>
|
</style>
|
||||||
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; background:#f5f5f5; color:#333; padding:8px 12px; border-radius:4px; border-left:4px solid #1890ff; display:flex; justify-content:space-between; align-items:center;">
|
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; background:#f5f5f5; color:#333; padding:4px 6px; border-radius:4px; border-left:4px solid #1890ff; display:flex; justify-content:space-between; align-items:center;">
|
||||||
<div style="display:flex; align-items:center; gap:8px;">
|
<div style="display:flex; align-items:center; gap:8px;">
|
||||||
<span>⚙️ 筛选配置</span>
|
<span>⚙️ 筛选配置</span>
|
||||||
<button id="ms-extract-options-btn" class="ms-tooltip-btn" data-tooltip="从当前页面获取筛选项目并更新到脚本配置中" style="background:none; border:none; cursor:pointer; color:#1890ff; padding:2px; display:flex; align-items:center; justify-content:center; border-radius:4px; outline:none;">
|
<button id="ms-extract-options-btn" class="ms-tooltip-btn" data-tooltip="从当前页面获取筛选项目并更新到脚本配置中" style="background:none; border:none; cursor:pointer; color:#1890ff; padding:2px; display:flex; align-items:center; justify-content:center; border-radius:4px; outline:none;">
|
||||||
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
<svg viewBox="0 0 24 24" width="13" height="13" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<polyline points="23 4 23 10 17 10"></polyline>
|
<polyline points="23 4 23 10 17 10"></polyline>
|
||||||
<polyline points="1 20 1 14 7 14"></polyline>
|
<polyline points="1 20 1 14 7 14"></polyline>
|
||||||
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
||||||
@@ -229,11 +229,11 @@
|
|||||||
<div id="ms-materials-container" style="display:grid; grid-template-columns:repeat(4, 1fr); gap:8px 4px;">${buildCheckboxes('materials', FILTER_OPTIONS.materials)}</div>
|
<div id="ms-materials-container" style="display:grid; grid-template-columns:repeat(4, 1fr); gap:8px 4px;">${buildCheckboxes('materials', FILTER_OPTIONS.materials)}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:8px 12px; border-radius:4px; border-left:4px solid #1890ff;">🛡️ 排除配置</div>
|
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:4px 6px; border-radius:4px; border-left:4px solid #1890ff;">🛡️ 排除配置</div>
|
||||||
<div style="margin-bottom:15px;">
|
<div style="margin-bottom:15px;">
|
||||||
<textarea id="ms-filter-excludes" placeholder="在此输入不要的数据组合,空格分隔,一行一条。\n例如输入:盘螺 Φ8\n则会精确排除所有线径为Φ8的盘螺,而保留Φ8-10。" style="width:100%; height:72px; padding:6px 8px; font-size:12px; border:1px solid #ccc; border-radius:4px; outline:none; resize:vertical; box-sizing:border-box; line-height:1.5;">${savedFilters.excludes || ''}</textarea>
|
<textarea id="ms-filter-excludes" placeholder="在此输入不要的数据组合,空格分隔,一行一条。\n例如输入:盘螺 Φ8\n则会精确排除所有线径为Φ8的盘螺,而保留Φ8-10。" style="width:100%; height:88px; padding:6px 8px; font-size:12px; border:1px solid #ccc; border-radius:4px; outline:none; resize:vertical; box-sizing:border-box; line-height:1.5;">${savedFilters.excludes || ''}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:8px 12px; border-radius:4px; border-left:4px solid #1890ff;">📤 导出配置</div>
|
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:4px 6px; border-radius:4px; border-left:4px solid #1890ff;">📤 导出配置</div>
|
||||||
<div style="margin-bottom:12px; display:flex; gap:10px; align-items:flex-end;">
|
<div style="margin-bottom:12px; display:flex; gap:10px; align-items:flex-end;">
|
||||||
<div style="flex:1;">
|
<div style="flex:1;">
|
||||||
<div style="font-size:13px; color:#333; font-weight:bold; margin-bottom:6px;">格式</div>
|
<div style="font-size:13px; color:#333; font-weight:bold; margin-bottom:6px;">格式</div>
|
||||||
@@ -247,7 +247,7 @@
|
|||||||
<input type="text" id="ms-filter-filename" value="${savedFilters.exportFilename || '钢材透视价格表'}" style="width:100%; padding:4px 8px; font-size:13px; height:28px; box-sizing:border-box; border:1px solid #ccc; border-radius:4px; outline:none;">
|
<input type="text" id="ms-filter-filename" value="${savedFilters.exportFilename || '钢材透视价格表'}" style="width:100%; padding:4px 8px; font-size:13px; height:28px; box-sizing:border-box; border:1px solid #ccc; border-radius:4px; outline:none;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:8px 12px; border-radius:4px; border-left:4px solid #1890ff; display:flex; justify-content:space-between; align-items:center;">
|
<div style="font-size:14px; font-weight:bold; margin-bottom:15px; margin-top:15px; background:#f5f5f5; color:#333; padding:4px 6px; border-radius:4px; border-left:4px solid #1890ff; display:flex; justify-content:space-between; align-items:center;">
|
||||||
<span>🛠️ 开发者选项</span>
|
<span>🛠️ 开发者选项</span>
|
||||||
<label class="ms-switch">
|
<label class="ms-switch">
|
||||||
<input type="checkbox" id="ms-dev-mode-switch" ${savedFilters.devMode ? 'checked' : ''}>
|
<input type="checkbox" id="ms-dev-mode-switch" ${savedFilters.devMode ? 'checked' : ''}>
|
||||||
@@ -301,7 +301,12 @@
|
|||||||
|
|
||||||
gearBtn.addEventListener('click', () => {
|
gearBtn.addEventListener('click', () => {
|
||||||
tooltip.style.display = 'none';
|
tooltip.style.display = 'none';
|
||||||
panel.style.display = panel.style.display === 'none' ? 'block' : 'none';
|
if (panel.style.display === 'none') {
|
||||||
|
syncUIWithFilters(loadSavedFilters());
|
||||||
|
panel.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
panel.style.display = 'none';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 组装 DOM
|
// 组装 DOM
|
||||||
@@ -312,7 +317,7 @@
|
|||||||
document.body.appendChild(container);
|
document.body.appendChild(container);
|
||||||
|
|
||||||
// 初始化及绑定全选事件
|
// 初始化及绑定全选事件
|
||||||
const updateAllSelectAllStates = () => {
|
function updateAllSelectAllStates() {
|
||||||
['names', 'specs', 'materials'].forEach(group => {
|
['names', 'specs', 'materials'].forEach(group => {
|
||||||
const selectAllCheckbox = document.getElementById(`ms-selectall-${group}`);
|
const selectAllCheckbox = document.getElementById(`ms-selectall-${group}`);
|
||||||
const container = document.getElementById(`ms-${group}-container`);
|
const container = document.getElementById(`ms-${group}-container`);
|
||||||
@@ -322,7 +327,50 @@
|
|||||||
selectAllCheckbox.checked = allChecked;
|
selectAllCheckbox.checked = allChecked;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function syncUIWithFilters(filters) {
|
||||||
|
['names', 'specs', 'materials'].forEach(group => {
|
||||||
|
const container = document.getElementById(`ms-${group}-container`);
|
||||||
|
if (container) {
|
||||||
|
container.querySelectorAll('input[type="checkbox"]').forEach(cb => {
|
||||||
|
cb.checked = filters[group] && filters[group].includes(cb.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const excludesEl = document.getElementById('ms-filter-excludes');
|
||||||
|
if (excludesEl) excludesEl.value = filters.excludes || '';
|
||||||
|
const formatEl = document.getElementById('ms-filter-format');
|
||||||
|
if (formatEl) formatEl.value = filters.exportFormat || 'xlsx';
|
||||||
|
const filenameEl = document.getElementById('ms-filter-filename');
|
||||||
|
if (filenameEl) filenameEl.value = filters.exportFilename || '钢材透视价格表';
|
||||||
|
|
||||||
|
const devModeEl = document.getElementById('ms-dev-mode-switch');
|
||||||
|
if (devModeEl) {
|
||||||
|
devModeEl.checked = !!filters.devMode;
|
||||||
|
const devContainer = document.getElementById('ms-dev-options-container');
|
||||||
|
if (devContainer) devContainer.style.display = filters.devMode ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
const debugModeEl = document.getElementById('ms-debug-mode');
|
||||||
|
if (debugModeEl) {
|
||||||
|
debugModeEl.checked = !!filters.debugMode;
|
||||||
|
const btn = document.getElementById('ms-debug-mode-btn');
|
||||||
|
if (btn) {
|
||||||
|
if (debugModeEl.checked) {
|
||||||
|
btn.style.background = '#ff4d4f';
|
||||||
|
btn.style.color = '#fff';
|
||||||
|
btn.style.borderColor = '#ff4d4f';
|
||||||
|
btn.innerText = 'DEBUG_MODE ON';
|
||||||
|
} else {
|
||||||
|
btn.style.background = '#f5f5f5';
|
||||||
|
btn.style.color = '#999';
|
||||||
|
btn.style.borderColor = '#d9d9d9';
|
||||||
|
btn.innerText = 'DEBUG_MODE OFF';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateAllSelectAllStates();
|
||||||
|
}
|
||||||
|
|
||||||
['names', 'specs', 'materials'].forEach(group => {
|
['names', 'specs', 'materials'].forEach(group => {
|
||||||
const selectAllCheckbox = document.getElementById(`ms-selectall-${group}`);
|
const selectAllCheckbox = document.getElementById(`ms-selectall-${group}`);
|
||||||
@@ -466,6 +514,7 @@
|
|||||||
|
|
||||||
document.getElementById('ms-close-btn').addEventListener('click', () => {
|
document.getElementById('ms-close-btn').addEventListener('click', () => {
|
||||||
panel.style.display = 'none';
|
panel.style.display = 'none';
|
||||||
|
syncUIWithFilters(loadSavedFilters());
|
||||||
});
|
});
|
||||||
|
|
||||||
// 点击外部关闭面板 (不保存)
|
// 点击外部关闭面板 (不保存)
|
||||||
|
|||||||
Reference in New Issue
Block a user