Fix module 19/9 matching so short IDs do not scan full row text.
Substring search for 9 and 19 matched timestamps and unrelated numbers and disconnected all sessions. Match those IDs only when Product or Feature cells equal exactly 19 or 9; keep PTW_* as row substring match. Rebuild distributables. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6274341ef5
commit
d3d45d90c3
8 files changed
+53
-17
No files matched your search
+22
-4
@@ -4,10 +4,12 @@
|
||||
|
||||
const TARGET_KEYWORDS = [
|
||||
'PTW_DATAEXCHANGE', 'PTW_ARC_FLASH', 'PTW_DEVEVAL', 'PTW_AFAULT',
|
||||
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363',
|
||||
'19', '9'
|
||||
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363'
|
||||
];
|
||||
|
||||
/** Matched only against Product / Feature cells (exact text), never whole-row substring — bare "9"/"19" match almost every row. */
|
||||
const TARGET_PRODUCT_FEATURE_IDS = ['19', '9'];
|
||||
|
||||
window.__ptw_logQueue = window.__ptw_logQueue || [];
|
||||
window.__ptw_running = window.__ptw_running !== false;
|
||||
|
||||
@@ -16,13 +18,29 @@
|
||||
window.__ptw_logQueue.push(`[${t}] ${msg}`);
|
||||
}
|
||||
|
||||
function productFeatureCells(row) {
|
||||
var cells = row.querySelectorAll('td');
|
||||
if (cells.length < 5) return { product: '', feature: '' };
|
||||
var product = (cells[3] && cells[3].innerText) ? cells[3].innerText.replace(/\s+/g, ' ').trim() : '';
|
||||
var feature = (cells[4] && cells[4].innerText) ? cells[4].innerText.replace(/\s+/g, ' ').trim() : '';
|
||||
return { product: product, feature: feature };
|
||||
}
|
||||
|
||||
function matchesProductFeatureId(product, feature) {
|
||||
return TARGET_PRODUCT_FEATURE_IDS.some(function (id) {
|
||||
return product === id || feature === id;
|
||||
});
|
||||
}
|
||||
|
||||
function scanAndDisconnect() {
|
||||
if (!window.__ptw_running) return;
|
||||
const rows = document.querySelectorAll('#mydata table.list tr');
|
||||
rows.forEach(function (row) {
|
||||
const rowText = row.innerText;
|
||||
const hasMatch = TARGET_KEYWORDS.some(function (k) { return rowText.indexOf(k) !== -1; });
|
||||
if (hasMatch) {
|
||||
var pf = productFeatureCells(row);
|
||||
const keywordMatch = TARGET_KEYWORDS.some(function (k) { return rowText.indexOf(k) !== -1; });
|
||||
const idMatch = matchesProductFeatureId(pf.product, pf.feature);
|
||||
if (keywordMatch || idMatch) {
|
||||
const disconnectLink = row.querySelector('a.sbutton');
|
||||
if (disconnectLink && disconnectLink.textContent.indexOf('Disconnect') !== -1) {
|
||||
const itemName = (rowText.split('\t')[0] || '').trim() || 'Item';
|
||||
|
||||
Reference in new issue
Block a user