// ==UserScript== // @name HY POD快速关联 // @namespace http://tampermonkey.net/ // @license MIT // @version 2024-8-4 // @description POD快速关联 F2 多件 // @author lyw // @match https://www.haoyipod.com/* // @match https://www2.haoyipod.com/* // @match https://www.haoyipodeur.com/* // @match https://www.ecofengpod.com/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @run-at document-end // @grant GM_addStyle // @require https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/element-ui/2.15.6/index.min.js // @resource element-ui-css https://cdnjs.cloudflare.com/ajax/libs/element-ui/2.15.6/theme-chalk/index.min.css // ==/UserScript== (function () { 'use strict'; // Inject Element UI CSS GM_addStyle('@import url("https://cdnjs.cloudflare.com/ajax/libs/element-ui/2.15.6/theme-chalk/index.min.css");'); // Create a Vue instance for Element UI const app = document.createElement('div'); document.body.appendChild(app); // Define Vue component with Element UI dialog new Vue({ el: app, data: { dialogVisible: false, inputValue: '' }, template: `
确认 取消
`, methods: { handleClose() { this.inputValue = ''; // 清空输入框 }, async confirm() { let processedValue = this.inputValue.split(" "); console.log(processedValue); console.log(); const inp = document.querySelectorAll('.el-form.finished-edit .finished-form .el-form-item__content .el-col.el-col-5'); inp.forEach(async (item,index) => { await item.click() const nextElementSibling = item.parentNode.nextElementSibling; if (nextElementSibling) { const btn = nextElementSibling.querySelector('button'); if (btn) { // 执行按钮的点击操作或其他逻辑 await btn.click(); const nextElementSibling = item.parentNode.nextElementSibling; if (nextElementSibling) { const inputElements = nextElementSibling.querySelector('input[placeholder="第三方SKU"]') inputElements.focus(); console.log(processedValue[index]); document.execCommand('selectAll', false, null); document.execCommand('insertText', false, processedValue[index]); } } } else { console.log('没有找到下个兄弟元素'); } // 移除焦点,避免焦点仍在最后一个输入框 document.activeElement.blur(); this.dialogVisible = false; // 关闭对话框 }) // 移除焦点,避免焦点仍在最后一个输入框 document.activeElement.blur(); this.dialogVisible = false; // 关闭对话框 }, }, mounted() { // 监听 F2 键触发事件 window.addEventListener('keydown', (event) => { if (event.key === 'F2') { this.dialogVisible = true; // 按下 F2 键时显示对话框 } if (event.key === 'F8') { var iframe = document.createElement('iframe'); iframe.style.display = 'none'; // 这里让 iframe 隐藏,不占空间 document.body.appendChild(iframe); document.querySelectorAll('.el-table__fixed-body-wrapper tbody .el-table__row').forEach(item=>{ if (item.querySelectorAll('[data-v-52763079].shop-item')[5].innerHTML.split(':')[1] != 1){ item.style.backgroundColor = 'yellow'; item.querySelector('input[type="checkbox"]').click() // iframe.contentWindow.console.log(item) } }) } // 监听 Enter 键触发确认操作 if (this.dialogVisible && (event.key === 'Enter' || event.key === 'NumpadEnter')) { this.confirm(); // 按下 Enter 键时执行 confirm 操作 } }); // 聚焦输入框 this.$watch('dialogVisible', (newVal) => { if (newVal) { this.$nextTick(() => { // 确保 Vue 更新 DOM 后,聚焦输入框 this.$refs.inputField.$el.querySelector('input').focus(); }); } }); } }); })();