Opened 4 weeks ago
Last modified 4 weeks ago
#37 new defect
docker
| Reported by: | elven | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | component1 | Version: | |
| Keywords: | Cc: |
Description
172.16.1.20 LXC on PVE01
root: ji9wnjsoft
docker portainer web: https://172.16.1.20:9443 (admin/ji9wnjsoft@2026)
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](/trac/MIS/chrome/common/trac_banner.png)
wiki: http://172.16.1.20
elven@…/無蝦米叭叭狗狗
<script> (function() { /** * 1. 精準抓取評分者 (Voter) * 優先抓取導覽列文字,並排除系統關鍵字 */ function getVoterName() { try { const topItems = document.querySelectorAll('.v-app-bar .v-btn__content span'); for (let span of topItems) { let txt = span.innerText.trim(); // 排除常見的系統按鈕字眼 if (txt && !['HOME', 'SEARCH', '主頁', '搜尋', 'PRINT', 'SHARE', 'LOGOUT', '點讚'].includes(txt.toUpperCase())) { return txt; } } // 備案:嘗試從 Vue Store 抓取 const vueStore = document.getElementById('app')?.__vue__?.$store?.state; if (vueStore && vueStore.user && vueStore.user.name) return vueStore.user.name; } catch(e) { console.error("Voter fetch error:", e); } return "Unknown_Voter"; } /** * 2. 注入按鈕與處理點擊事件 */ function injectBtn() { // 防止重複注入 if (document.getElementById('wiki-like-btn')) return; // 定位紅框區 (分享圖示旁) const shareIcon = document.querySelector('.mdi-share-variant'); if (!shareIcon) return; const actionBar = shareIcon.closest('div'); if (!actionBar) return; const btn = document.createElement('button'); btn.id = 'wiki-like-btn'; btn.type = 'button'; btn.className = 'v-btn v-btn--icon v-btn--round theme--light v-size--default primary--text'; btn.style.marginRight = '8px'; btn.innerHTML = ` <span class="v-btn__content"> <i class="v-icon notranslate mdi mdi-thumb-up theme--light" style="font-size: 24px;"></i> </span> `; btn.onclick = function() { const targetBtn = this; function processLike() { // 抓取頁面數據 const pTitle = document.querySelector('h1')?.innerText.replace('¶', '').trim() || "Untitled"; const pageEl = document.querySelector('page'); const pAuthor = pageEl ? pageEl.getAttribute('author-name') : "Administrator"; const vName = getVoterName(); // 解決 SPA 渲染延遲:若標題尚未載入則重試 if (pTitle === "Untitled Page" || pTitle === "Untitled") { setTimeout(processLike, 300); return; } console.log(`[KPI 傳送至 GAS] 標題: ${pTitle} | 作者: ${pAuthor} | 評分者: ${vName}`); // 您的 Google Apps Script 網址 const gasUrl = "https://script.google.com/macros/s/AKfycbxA3h5aOSlu0zN7iGwx1ii1TGN4txAxtixhfGNECs2Ra0Ph3NnCBnBkmfRYaz6OyPED/exec"; // 組合 API 網址參數 const finalUrl = `${gasUrl}?title=${encodeURIComponent(pTitle)}&author=${encodeURIComponent(pAuthor)}&voter=${encodeURIComponent(vName)}&content=${encodeURIComponent('👍')}`; // 使用 fetch 發送 (使用 no-cors 模式以避開跨網域限制) fetch(finalUrl, { mode: 'no-cors' }) .then(() => { // 介面回饋:變色並換成打勾圖示 targetBtn.style.color = '#4CAF50'; targetBtn.innerHTML = '<span class="v-btn__content"><i class="v-icon mdi mdi-check-circle"></i></span>'; alert(`✅ 點讚已記錄!\n\n頁面:${pTitle}\n作者:${pAuthor}\n評分者:${vName}`); }) .catch(err => { console.error("GAS Submit Error:", err); alert("❌ 傳送失敗,請確認網路連線或 GAS 權限。"); }); } processLike(); }; // 將按鈕插入到操作列的最前面 actionBar.prepend(btn); } // 設定定時器持續檢查按鈕是否存在 (每 1.5 秒執行一次) setInterval(injectBtn, 1500); })(); </script>