{"id":609,"date":"2025-08-11T16:37:49","date_gmt":"2025-08-11T08:37:49","guid":{"rendered":"https:\/\/www.subkme.com\/?p=609"},"modified":"2025-08-14T16:26:47","modified_gmt":"2025-08-14T08:26:47","slug":"%e3%80%90%e6%b2%b9%e7%8c%b4%e8%84%9a%e6%9c%ac%e3%80%91%e5%bf%ab%e6%8d%b7%e5%b1%95%e7%8e%b0%e7%9c%81%e5%86%85%e5%85%ac%e6%96%87%e4%b8%bb%e8%a6%81%e9%a2%86%e5%af%bc%e5%90%8e%e7%bb%ad%e6%8f%90%e4%ba%a4","status":"publish","type":"post","link":"https:\/\/subk.me\/?p=609","title":{"rendered":"\u3010\u6cb9\u7334\u811a\u672c\u3011\u5feb\u6377\u5c55\u73b0\u7701\u5185\u516c\u6587\u4e3b\u8981\u9886\u5bfc\u540e\u7eed\u63d0\u4ea4\u4eba\u5458"},"content":{"rendered":"<p>\u5904\u7406\u7701\u5185OA\u6587\u4ef6\uff0c\u5feb\u901f\u5c55\u73b0\u4e3b\u8981\u9886\u5bfc\u63d0\u4ea4\u7684\u540e\u7eed\u4eba\u5458\u5217\u8868\uff0c\u907f\u514d\u91cd\u590d\u63d0\u4ea4\u3002<\/p>\n<pre><code>\/\/ ==UserScript==\n\/\/ @name         \u7701\u5185OA\u6d41\u7a0b\u8ddf\u8e2a\u63d0\u53d6XXX\u9001\u529e\u7406\u540e\u7eed\u4eba\u5458\uff08\u9690\u85cfiframe+\u901a\u4fe1\u7248\uff09\n\/\/ @namespace    http:\/\/tampermonkey.net\/\n\/\/ @version      1.15.0\n\/\/ @description  \u65e0\u611f\u540e\u53f0\u52a0\u8f7d\u6d41\u7a0b\u8ddf\u8e2a\u9875\u63d0\u53d6\u540e\u7eed\u4eba\u5458\uff0c\u4fdd\u7559\u539fiframe\u903b\u8f91\u4e0e\u901a\u4fe1\u673a\u5236\uff0c\u624b\u52a8\u70b9\u51fb\u4ecd\u53ef\u6b63\u5e38\u663e\u793a\u3002\n\/\/ @author       subk\n\/\/ @match        http:\/\/XXXXXX\/newWorkSheet\/*\n\/\/ @match        http:\/\/XXXXXX\/OADocument\/document\/*\n\/\/ @match        http:\/\/XXXXXX\/mocha.component.processtrack.v5\/process\/processinfo*\n\/\/ @grant        none\n\/\/ @run-at       document-end\n\/\/ ==\/UserScript==\n\n(function () {\n    &#039;use strict&#039;;\n\n    const TARGET_HANDLER_NAME = &quot;XXX&quot;;\n    const ACTION_KEYWORD = &quot;\u9001\u529e\u7406&quot;;\n\n    \/\/ ================= \u4e3b\u9875\u9762\u903b\u8f91 =================\n    if (location.pathname.includes(&#039;\/newWorkSheet\/&#039;) ||\n        location.pathname.includes(&#039;\/OADocument\/document\/&#039;)) {\n\n        function waitForElement(selector, timeout = 15000) {\n            return new Promise((resolve, reject) =&gt; {\n                const element = document.querySelector(selector);\n                if (element) { resolve(element); return; }\n                const observer = new MutationObserver(() =&gt; {\n                    const el = document.querySelector(selector);\n                    if (el) { observer.disconnect(); resolve(el); }\n                });\n                observer.observe(document.body, { childList: true, subtree: true });\n                if (timeout &gt; 0) {\n                    setTimeout(() =&gt; { observer.disconnect(); reject(new Error(`Timeout waiting for ${selector}`)); }, timeout);\n                }\n            });\n        }\n\n        async function openHiddenProcessTrack() {\n            try {\n                const trackButton = await waitForElement(&#039;button[data-action=&quot;trace&quot;]&#039;, 10000);\n\n                let trackUrl = trackButton.getAttribute(&#039;data-url&#039;);\n\n                if (!trackUrl) {\n                    \/\/ \u6a21\u62df\u70b9\u51fb\u83b7\u53d6\u771f\u5b9eURL\n                    trackButton.click();\n                    const iframeLayer = await waitForElement(&#039;.layui-layer-iframe iframe&#039;, 5000);\n                    trackUrl = iframeLayer.src;\n\n                    \/\/ \u5173\u95ed\u5f39\u7a97\n                    const closeBtn = document.querySelector(&#039;.layui-layer-close&#039;);\n                    if (closeBtn) closeBtn.click();\n                }\n\n                \/\/ \u521b\u5efa\u9690\u85cf iframe\n                const hiddenIframe = document.createElement(&#039;iframe&#039;);\n                hiddenIframe.style.display = &#039;none&#039;;\n                hiddenIframe.src = trackUrl;\n                document.body.appendChild(hiddenIframe);\n\n            } catch (error) {\n                displayNames([&#039;\u83b7\u53d6\u6d41\u7a0b\u8ddf\u8e2aURL\u5931\u8d25&#039;]);\n            }\n        }\n\n        function displayNames(names) {\n            if (!Array.isArray(names) || names.length === 0) {\n                names = [&#039;\u672a\u627e\u5230\u540e\u7eed\u4eba\u5458&#039;];\n            }\n            const existingBox = document.getElementById(&#039;tm-next-handlers-display&#039;);\n            if (existingBox) existingBox.remove();\n\n            const displayBox = document.createElement(&#039;div&#039;);\n            displayBox.id = &#039;tm-next-handlers-display&#039;;\n            displayBox.style.cssText = &#039;position:fixed;top:10px;right:10px;background-color:#e8f4ff;border:1px solid #1890ff;border-radius:4px;padding:10px;z-index:999999;font-size:14px;box-shadow:0 2px 8px rgba(0,0,0,0.15);max-width:300px;word-wrap:break-word;font-family:monospace;&#039;;\n            displayBox.innerHTML = `&lt;strong style=&quot;color:#1890ff;&quot;&gt;${TARGET_HANDLER_NAME}${ACTION_KEYWORD}\u540e\u7eed:&lt;\/strong&gt;&lt;br&gt;` +\n                names.map(name =&gt; `&lt;span style=&quot;display:inline-block;margin:3px 5px;background-color:#f0f0f0;padding:2px 5px;border-radius:3px;&quot;&gt;${name}&lt;\/span&gt;`).join(&#039; &#039;);\n            document.body.appendChild(displayBox);\n        }\n\n        \/\/ \u63a5\u6536 iframe \u53d1\u6765\u7684\u7ed3\u679c\n        window.addEventListener(&#039;message&#039;, (event) =&gt; {\n            if (event.data &amp;&amp; event.data.type === &#039;tm-next-handlers&#039;) {\n                displayNames(event.data.names);\n            }\n        });\n\n        window.addEventListener(&#039;load&#039;, openHiddenProcessTrack);\n    }\n\n    \/\/ ================= iframe \u9875\u9762\u903b\u8f91 =================\n    if (location.pathname.includes(&#039;\/mocha.component.processtrack.v5\/process\/processinfo&#039;)) {\n        \/\/ \u5728\u6d41\u7a0b\u8ddf\u8e2a\u9875\u6267\u884c\u539f\u6709\u63d0\u53d6\u903b\u8f91\n        function extractNames() {\n            try {\n                const handlerSpans = document.querySelectorAll(&#039;span.handler&#039;);\n                for (let span of handlerSpans) {\n                    if (span.textContent.trim() === TARGET_HANDLER_NAME) {\n                        const handlerRow = span.closest(&#039;tr&#039;);\n                        if (!handlerRow) continue;\n\n                        let submitLink = null;\n                        const nextRow = handlerRow.nextElementSibling;\n                        if (nextRow) {\n                            const linksInNextRow = nextRow.querySelectorAll(&#039;a.submit-path-link&#039;);\n                            for (const link of linksInNextRow) {\n                                if (link.textContent.includes(ACTION_KEYWORD)) {\n                                    submitLink = link; break;\n                                }\n                            }\n                        }\n                        if (!submitLink) {\n                            const linksInRow = handlerRow.querySelectorAll(&#039;a.submit-path-link&#039;);\n                            for (const link of linksInRow) {\n                                if (link.textContent.includes(ACTION_KEYWORD)) {\n                                    submitLink = link; break;\n                                }\n                            }\n                        }\n                        if (submitLink) {\n                            const onMouseOverAttr = submitLink.getAttribute(&#039;onmouseover&#039;);\n                            if (onMouseOverAttr &amp;&amp; onMouseOverAttr.startsWith(&#039;showTip&#039;)) {\n                                const matches = onMouseOverAttr.match(\/showTip\\(\\s*this\\s*,\\s*[&#039;&quot;]([^&#039;&quot;]*)[&#039;&quot;]\\s*,\\s*[&#039;&quot;]([^&#039;&quot;]*)[&#039;&quot;]\\s*\\)\/);\n                                if (matches &amp;&amp; matches.length &gt;= 3) {\n                                    const mc = matches[1], tiid = matches[2];\n                                    return fetchNextHandlers(mc, tiid);\n                                }\n                            }\n                        }\n                    }\n                }\n                return [];\n            } catch (e) {\n                return [];\n            }\n        }\n\n        function fetchNextHandlers(mc, tiid) {\n            try {\n                let basePath = &#039;\/mocha.component.processtrack.v5&#039;;\n                if (typeof window.FRAMEWORK_BASE_PATH !== &#039;undefined&#039;) {\n                    basePath = window.FRAMEWORK_BASE_PATH;\n                }\n                const xhr = new XMLHttpRequest();\n                xhr.open(&#039;GET&#039;, `${basePath}\/process\/getNextHandlers?mc=${encodeURIComponent(mc)}&amp;tiid=${encodeURIComponent(tiid)}`, false);\n                xhr.withCredentials = true;\n                xhr.send();\n                if (xhr.status === 200) {\n                    const data = JSON.parse(xhr.responseText);\n                    if (data.result === true &amp;&amp; data.data &amp;&amp; Array.isArray(data.data)) {\n                        return data.data.map(item =&gt; item.handler).filter(Boolean);\n                    }\n                }\n            } catch (e) {}\n            return [];\n        }\n\n        window.addEventListener(&#039;load&#039;, () =&gt; {\n            const names = extractNames();\n            \/\/ \u53d1\u9001\u7ed9\u7236\u9875\u9762\n            if (window.parent &amp;&amp; window.parent !== window) {\n                window.parent.postMessage({ type: &#039;tm-next-handlers&#039;, names }, &#039;*&#039;);\n            }\n        });\n    }\n\n})();\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5904\u7406\u7701\u5185OA\u6587\u4ef6\uff0c\u5feb\u901f\u5c55\u73b0\u4e3b\u8981\u9886\u5bfc\u63d0\u4ea4\u7684\u540e\u7eed\u4eba\u5458\u5217\u8868\uff0c\u907f\u514d\u91cd\u590d\u63d0\u4ea4\u3002 \/\/ ==UserScript== \/\/ [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[32],"class_list":["post-609","post","type-post","status-publish","format-standard","hentry","category-it","tag-32"],"_links":{"self":[{"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/posts\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/subk.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=609"}],"version-history":[{"count":2,"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions"}],"predecessor-version":[{"id":613,"href":"https:\/\/subk.me\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions\/613"}],"wp:attachment":[{"href":"https:\/\/subk.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/subk.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/subk.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}