Skip to content

Instantly share code, notes, and snippets.

@exkuretrol
Created June 6, 2026 09:26
Show Gist options
  • Select an option

  • Save exkuretrol/39ed8cdcfd99972f3a5e6380f4e02323 to your computer and use it in GitHub Desktop.

Select an option

Save exkuretrol/39ed8cdcfd99972f3a5e6380f4e02323 to your computer and use it in GitHub Desktop.
減碳存摺自動填資料送出 bookmarklet
javascript:(()=>{const D={name:"王小明",phone:"0912345678",email:"you@example.com",address:"台北市信義區市府路1號"};const f=document.querySelector('form[id^="gform_"]');if(!f){alert('找不到表單');return}const set=(el,v)=>{if(!el||!v)return;el.value=v;el.dispatchEvent(new Event('input',{bubbles:true}));el.dispatchEvent(new Event('change',{bubbles:true}))};const pick=ks=>{for(const g of f.querySelectorAll('.gfield')){if(ks.some(k=>g.textContent.includes(k))){const i=g.querySelector('input:not([type=hidden]):not([type=radio]):not([type=checkbox]),textarea');if(i)return i}}return null};set(pick(['姓名']),D.name);set(f.querySelector('input[type=tel]')||pick(['手機','電話']),D.phone);set(f.querySelector('input[type=email]')||pick(['信箱']),D.email);let a=pick(['收件地址','地址','住址']);if(!a||a.value){a=[...f.querySelectorAll('input[type=text],textarea')].find(i=>!i.value&&i.offsetParent)}set(a,D.address);f.querySelectorAll('input[type=checkbox]').forEach(c=>{if(!c.checked)c.click()});const s=f.querySelector('input[type=submit],button[type=submit],[id^="gform_submit_button"]');if(s){s.scrollIntoView({block:'center'});s.click()}})();
@exkuretrol

exkuretrol commented Jun 6, 2026

Copy link
Copy Markdown
Author

在手機上需要在偏好的瀏覽器先建立書籤,網址設定為上面的 javascript 程式碼區段,書籤名字隨意。
執行時到目標頁面的網址欄位,輸入書籤名字點擊即可執行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment