You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Matter书签脚本,自动触发回车实现链接自动保存?

修改Matter书签脚本实现自动保存

原Matter书签脚本需要手动点击保存按钮,以下是修改后的单行脚本,添加1秒延迟确保弹窗加载完成后自动触发保存操作:

javascript:(()=>{async(o)=>{let e=window.document;await(async()=>new Promise((t)=>{if(e.readyState==="complete")return t(e.readyState);window.addEventListener("load",()=>t(e.readyState))})());const origin="https://web.getmatter.com";window.addEventListener("message",(e)=>{if(e.origin!==origin||e.data.type!=="ASK_PAGE_HTML")return;e.source.postMessage({type:"PAGE_HTML",payload:document.documentElement.outerHTML},origin)});const popup=window.open(`${origin}/bookmarklet/save?url=${encodeURIComponent(o.location.href)}`,"MATTER_SAVE","popup=1,width=500,height=250");setTimeout(()=>{try{const a=popup.document.querySelector('button[type="submit"],button:has-text("Save"),.save-button');a?a.click():popup.document.activeElement.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:true}))}catch(t){}},1000)}(window)})()

修改说明

  • 保存弹窗实例:捕获window.open返回的弹窗对象,用于后续操作
  • 1秒延迟定时器:等待弹窗页面完全加载,避免元素未找到的问题
  • 自动触发逻辑:
    1. 优先查找常见的保存按钮选择器(提交按钮、含"Save"文本的按钮、保存按钮类),找到后直接点击
    2. 如果按钮定位失败,自动对当前激活元素触发回车键,模拟手动提交
  • 异常捕获:包裹try/catch处理跨域访问可能出现的报错,避免脚本中断

内容的提问来源于stack exchange,提问作者Fede Gold

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 01:35:25