您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Modeling Helper
当前为
// ==UserScript== // @name MEST Modeling Helper // @namespace joyings.com.cn // @version 0.1 // @description Modeling Helper // @author zmz125000 // @match http://*/mest/* // @icon http://www.google.com/s2/favicons?domain=openwrt.org // @grant none // @license MIT // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js // @run-at document-end // ==/UserScript== (function () { 'use strict'; // Your code here... addClickActions(); function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function getElementsByXPath(xpath, parent) { let results = []; let query = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (let i = 0, length = query.snapshotLength; i < length; ++i) { results.push(query.snapshotItem(i)); } return results; } async function addClickActions() { if (!$('button:contains(" 新增一行 ")')[0]) { window.setTimeout(addClickActions, 500); console.log("waiting..."); return } await sleep(250); var semiIndex = $('th:contains(" 半成品/成品名称 ")')[0].cellIndex; var materialIndex = $('th:contains(" 所需物料集 ")')[0].cellIndex; var procIndex = $('th:contains(" 上级序号 ")')[0].cellIndex; $('button:contains(" 新增一行 ")')[0].addEventListener('click', async function (e) { let bodyRows = document.querySelectorAll('[class="edit-cell"]')[0].closest('table').lastChild.rows; // 设置上级序号 let lastIndexCell = bodyRows.item(bodyRows.length - 1).cells.item(procIndex); lastIndexCell.firstChild.firstChild.firstChild.click(); await sleep(50); // lastIndexCell.firstChild.firstChild.firstChild.lastChild.click(); lastIndexCell.firstChild.firstChild.firstChild.firstChild.click() await sleep(150); $('button:contains(" 选择 ")')[bodyRows.length - 2].click(); await sleep(150); // 设置物料 let prevSemi = bodyRows.item(bodyRows.length - 2).cells.item(semiIndex).firstChild.firstChild.firstChild.textContent; let lastMatCell = bodyRows.item(bodyRows.length - 1).cells.item(materialIndex); lastMatCell.firstChild.firstChild.click(); await sleep(150); $('button:contains("新增行")')[0].click(); await sleep(150); document.querySelector('[placeholder="物料选择"]').closest('div').querySelector('button').click(); await sleep(150); document.querySelectorAll('[placeholder="存货名称"]')[1].value = prevSemi; document.querySelectorAll('[placeholder="存货名称"]')[1].dispatchEvent(new Event('input', { bubbles: true })); await sleep(150); $('button:contains(" 搜索 ")')[0].click(); //$('button:contains(" 选择 ")')[0].click(); }) } })();