您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Modeling Helper
当前为
// ==UserScript== // @name MEST Modeling Helper // @namespace joyings.com.cn // @version 0.4.7 // @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(); addObserverIfDesiredNodeAvailable(); window.loaded = false; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function addObserverIfDesiredNodeAvailable() { var composeBox = document.querySelectorAll('[class="el-popup-parent--hidden"]')[0]; if (!composeBox) { //The node we need does not exist yet. //Wait 500ms and try again window.setTimeout(addObserverIfDesiredNodeAvailable, 500); return; } var config = { attributes: true, }; var composeObserver = new MutationObserver(function () { window.setTimeout(addClickActions, 500); composeObserver.disconnect(); addObserverIfDesiredNodeAvailable(); }); composeObserver.observe(composeBox, config); } async function addClickActions() { if (!$('button:contains(" 新增一行 ")')[0]) { window.loaded = false; await sleep(500); addClickActions(); return; } if (window.loaded) { return; } window.loaded = true; await sleep(250); var alias=document.querySelector('[placeholder="别名"]').closest('textarea').value; var semiIndex = $('th:contains(" 半成品/成品名称 ")')[0].cellIndex; var materialIndex = $('th:contains(" 所需物料集 ")')[0].cellIndex; var procIndex = $('th:contains(" 上级序号 ")')[0].cellIndex; if ($('div:contains(" 暂未设置工艺 ")')[0]) { $('button:contains(" 设置工艺版本 ")')[0].addEventListener('click', async function (e) { await sleep(150); $('button:contains(" 新增工艺版本 ")')[0].click(); await sleep(150); document.querySelectorAll('[placeholder="输入工艺版本名称"]')[0].value = "default"; document.querySelectorAll('[placeholder="输入工艺版本名称"]')[0].dispatchEvent(new Event('input', { bubbles: true })); await sleep(50); $('button:contains(" 选择 ")')[0].click(); }); } $('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(100); $('button:contains(" 选择 ")')[bodyRows.length - 1].click(); await sleep(100); // 设置物料 let prevSemi = ""; if (bodyRows.length > 1) { 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(100); $('button:contains("新增行")')[0].click(); await sleep(100); document.querySelector('[placeholder="物料选择"]').closest('div').querySelector('button').click(); await sleep(100); 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(); }); } })();