feat: initialize gomdown-helper with yt-dlp transfer flow

This commit is contained in:
tongki078
2026-02-26 11:43:44 +09:00
commit e8b7432594
123 changed files with 6094 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
{
"../../../../../@crx/manifest": {
"file": "assets/crx-manifest.js--9ZsUvq0.js",
"name": "crx-manifest.js",
"src": "../../../../../@crx/manifest",
"isEntry": true
},
"_browser-polyfill-CZ_dLIqp.js": {
"file": "assets/browser-polyfill-CZ_dLIqp.js",
"name": "browser-polyfill"
},
"_client-CBvt1tWS.js": {
"file": "assets/client-CBvt1tWS.js",
"name": "client",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"_downloadIntent-Dv31jC2S.js": {
"file": "assets/downloadIntent-Dv31jC2S.js",
"name": "downloadIntent"
},
"_index.ts-loader-DMyyuf2n.js": {
"file": "assets/index.ts-loader-DMyyuf2n.js",
"src": "_index.ts-loader-DMyyuf2n.js"
},
"_settings-Bo6W9Drl.js": {
"file": "assets/settings-Bo6W9Drl.js",
"name": "settings",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"src/background/index.ts": {
"file": "assets/index.ts-U2ACoZ75.js",
"name": "index.ts",
"src": "src/background/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js",
"_settings-Bo6W9Drl.js"
]
},
"src/config/index.html": {
"file": "assets/index.html-B0Kfv8fq.js",
"name": "index.html",
"src": "src/config/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_settings-Bo6W9Drl.js",
"_browser-polyfill-CZ_dLIqp.js"
],
"css": [
"assets/index-B2D5FcJM.css"
]
},
"src/content/index.ts": {
"file": "assets/index.ts-BGLNJwsP.js",
"name": "index.ts",
"src": "src/content/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js"
]
},
"src/popup/index.html": {
"file": "assets/index.html-Tb8yZAds.js",
"name": "index.html",
"src": "src/popup/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_browser-polyfill-CZ_dLIqp.js",
"_settings-Bo6W9Drl.js"
],
"css": [
"assets/index-D6aWDpYY.css"
]
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix WebExtension",
"description": "The name of the application"
},
"appShortName": {
"message": "Motrix WebExt",
"description": "The short_name (maximum of 12 characters recommended) is a short version of the app's name."
},
"appDescription": {
"message": "WebExtension for Motrix download manager",
"description": "The description of the application"
},
"browserActionTitle": {
"message": "Motrix WebExtension",
"description": "The title of the browser action button"
},
"extensionStatus": {
"message": "Extension status:",
"description": "Extension status"
},
"enableNotifications": {
"message": "Enable notifications:",
"description": "Enable Notifications"
},
"setKey": {
"message": "Set Key",
"description": "Set Key"
},
"setMinSize": {
"message": "Set minimum file size (mb)",
"description": "Set minimum file size"
},
"setSize": {
"message": "Set size",
"description": "Set size"
},
"keyInputPlaceholder": {
"message": "Motrix API Key",
"description": "Motrix API Key"
},
"blacklist": {
"message": "Blacklist",
"description": "Blacklist"
},
"saveBlacklist": {
"message": "Save blacklist",
"description": "Save blacklist"
},
"darkMode": {
"message": "Dark mode",
"description": "Dark mode"
},
"showOnlyAria": {
"message": "Show only Motrix downloads in the popup",
"description": "Show only Motrix downloads in the popup"
},
"hideChromeBar": {
"message": "Hide chrome download bar",
"description": "Hide chrome download bar"
},
"showContextOption": {
"message": "Show \"Download with gdown\" context option",
"description": "Show \"Download with gdown\" context option"
},
"downloadWithMotrix": {
"message": "Download with gdown",
"description": "Download with gdown"
},
"setPort": {
"message": "Set Port",
"description": "Set Port"
},
"downloadFallback": {
"message": "If launching in gdown fails, use the browser's default download manager",
"description": "If launching in gdown fails, use the browser's default download manager"
},
"useNativeHost": {
"message": "Use Native Messaging host for downloads",
"description": "Use Native Messaging host for downloads"
},
"activateAppOnDownload": {
"message": "Activate gdown app when transfer starts",
"description": "Activate gdown app when transfer starts"
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix 网页扩展",
"description": "应用程序名称"
},
"appShortName": {
"message": "Motrix 扩展",
"description": "应用程序缩略名称"
},
"appDescription": {
"message": "用于 Motrix 下载管理器的网页扩展",
"description": "应用程序描述"
},
"browserActionTitle": {
"message": "Motrix 网页扩展",
"description": "浏览器操作按钮标题"
},
"extensionStatus": {
"message": "扩展状态",
"description": "扩展状态"
},
"enableNotifications": {
"message": "允许桌面通知",
"description": "允许桌面通知"
},
"setKey": {
"message": "设置密钥",
"description": "设置密钥"
},
"setMinSize": {
"message": "设置最小下载文件 (mb)",
"description": "设置最小下载文件"
},
"setSize": {
"message": "设置大小",
"description": "设置大小"
},
"keyInputPlaceholder": {
"message": "Motrix API 密钥",
"description": "Motrix API 密钥"
},
"blacklist": {
"message": "黑名单",
"description": "黑名单"
},
"saveBlacklist": {
"message": "保存黑名单",
"description": "保存黑名单"
},
"darkMode": {
"message": "深色模式",
"description": "深色模式"
},
"showOnlyAria": {
"message": "在弹出窗口中仅显示 Motrix 下载",
"description": "在弹出窗口中仅显示 Motrix 下载"
},
"hideChromeBar": {
"message": "隐藏 Chrome 下载栏",
"description": "隐藏 Chrome 下载栏"
},
"showContextOption": {
"message": "显示“使用 gdown 下载”右键选项",
"description": "显示“使用 gdown 下载”右键选项"
},
"downloadWithMotrix": {
"message": "使用 gdown 下载",
"description": "使用 gdown 下载"
},
"setPort": {
"message": "设置端口",
"description": "设置端口"
},
"downloadFallback": {
"message": "如果 gdown 启动失败,则使用浏览器的默认下载管理器",
"description": "如果 gdown 启动失败,则使用浏览器的默认下载管理器"
},
"useNativeHost": {
"message": "使用 Native Messaging 主机传输下载",
"description": "使用 Native Messaging 主机传输下载"
},
"activateAppOnDownload": {
"message": "下载转交时激活 gdown 应用",
"description": "下载转交时激活 gdown 应用"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
const s=/\.(zip|7z|rar|tar|gz|bz2|xz|dmg|pkg|exe|msi|iso|torrent|pdf|mp4|mkv|mp3|flac|apk|deb|rpm|ipa|img|bin)(?:$|[?#])/i,p=/^(text\/html|text\/plain|application\/json|application\/javascript|application\/xml|text\/xml)/i,d=/(^|\/)(download|downloads|dl|get|file|files|attachment|attachments)(\/|$)/i;function i(n,t){try{return new URL(n,t)}catch{return null}}function w(n,t){const e=i(n,t);return e?e.toString():String(n||"")}function a(n,t){const e=i(n,t);return e?s.test(e.pathname||""):s.test(String(n||""))}function g(n){const t=String(n||"").replace(/-/g,"+").replace(/_/g,"/");try{return atob(t)}catch{return""}}function m(n){if(!d.test(n))return!1;const t=String(n||"").split("/").filter(Boolean),e=t[t.length-1]||"";return!e||e.includes(".")?!1:/^[a-z0-9_-]{12,}$/i.test(e)}function h(n){const t=n.searchParams,e=t.get("golink");if(e){const r=g(e);if(r&&s.test(r))return!0}const o=t.get("filename")||t.get("file")||t.get("name")||t.get("out");return!!(o&&s.test(o)||t.has("attachment")||t.has("download"))}function y(n,t){const e=i(n,t);return!e||!["http:","https:","ftp:"].includes(e.protocol)?!1:!!(a(e.toString())||h(e)||m(e.pathname||""))}function L(n){const t=Array.isArray(n?.responseHeaders)?n.responseHeaders:[],e=l=>{const c=String(l||"").toLowerCase(),u=t.find(f=>String(f?.name||"").toLowerCase()===c);return String(u?.value||"")},o=e("content-disposition").toLowerCase(),r=e("content-type").toLowerCase();return o.includes("attachment")||a(n.url||"")?!0:!r||p.test(r)?!1:r.startsWith("application/")||r.startsWith("audio/")||r.startsWith("video/")}export{L as a,y as i,w as n};

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#141820;color:#e6ebf7}.wrap{max-width:860px;margin:0 auto;padding:24px;display:grid;gap:12px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.card{background:#1f2530;border:1px solid #323b4a;border-radius:10px;padding:12px;display:grid;gap:8px}label{font-size:12px;color:#aeb8cc}input,textarea{border:1px solid #3c4658;border-radius:7px;background:#121721;color:#e6ebf7;padding:8px 10px}input[type=checkbox]{width:16px;height:16px}.row{display:flex;align-items:center;justify-content:space-between;gap:8px}.actions{display:flex;gap:8px}button{border:1px solid #5967f4;background:#5967f4;color:#fff;border-radius:8px;padding:8px 12px;font-weight:600;cursor:pointer}button.ghost{background:#232a36;border-color:#3b4658}@media(max-width:900px){.grid{grid-template-columns:1fr}}

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#151821;color:#e7ebf7;width:360px}.container{padding:14px;display:grid;gap:10px}h1{margin:0;font-size:14px}.field{display:grid;gap:6px}label{font-size:12px;color:#aeb6cc}input[type=text],input[type=number]{height:32px;border:1px solid #3e4658;border-radius:6px;padding:0 10px;background:#202532;color:#e7ebf7}.toggle{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:#cdd5ea}button{height:34px;border:1px solid #5562f0;border-radius:8px;background:#5562f0;color:#fff;font-weight:600;cursor:pointer}.media-panel{margin-top:6px;border:1px solid #384255;border-radius:8px;padding:8px;background:#1b202c;display:grid;gap:8px}.media-head{display:flex;align-items:center;justify-content:space-between;font-size:12px}.media-list{display:grid;gap:6px;max-height:150px;overflow:auto}.media-item{display:flex;align-items:center;justify-content:space-between;gap:8px}.media-meta{min-width:0;display:grid;gap:2px}.kind{font-size:11px;color:#8fc0ff}.url{font-size:11px;color:#c6d1e8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:250px}.mini{height:26px;min-width:44px;padding:0 8px;border-radius:6px;font-size:11px}.mini.ghost{background:#2a3140;border-color:#47546c;color:#d4def2}.empty{font-size:11px;color:#96a3bc}.status{font-size:12px;color:#8fe0a6;min-height:14px}

View File

@@ -0,0 +1,3 @@
import{c as p,j as e,R as a}from"./client-CBvt1tWS.js";import{g as j,s as m}from"./settings-Bo6W9Drl.js";import"./browser-polyfill-CZ_dLIqp.js";function u(){const[t,i]=a.useState(null),[l,r]=a.useState(""),[h,d]=a.useState("");a.useEffect(()=>{j().then(s=>{i(s),r((s.blacklist||[]).join(`
`))})},[]);const n=(s,c)=>{i(o=>o&&{...o,[s]:c})},x=async()=>{if(!t)return;const s={...t,minFileSize:Number(t.minFileSize||0),motrixPort:Number(t.motrixPort||16800),blacklist:l.split(`
`).map(c=>c.trim()).filter(Boolean)};await m(s),i(s),d("Saved"),window.setTimeout(()=>d(""),1500)};return t?e.jsxs("div",{className:"wrap",children:[e.jsx("h1",{children:"Gomdown Helper Settings"}),e.jsxs("div",{className:"grid",children:[e.jsxs("section",{className:"card",children:[e.jsx("label",{children:"RPC Secret"}),e.jsx("input",{value:t.motrixAPIkey,onChange:s=>n("motrixAPIkey",s.target.value)}),e.jsx("label",{children:"RPC Port"}),e.jsx("input",{type:"number",value:t.motrixPort,onChange:s=>n("motrixPort",Number(s.target.value||16800))}),e.jsx("label",{children:"Min file size (MB)"}),e.jsx("input",{type:"number",value:t.minFileSize,onChange:s=>n("minFileSize",Number(s.target.value||0))}),e.jsx("label",{children:"Blacklist (one per line)"}),e.jsx("textarea",{rows:8,value:l,onChange:s=>r(s.target.value)})]}),e.jsxs("section",{className:"card",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Extension enabled"}),e.jsx("input",{type:"checkbox",checked:t.extensionStatus,onChange:s=>n("extensionStatus",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Enable notifications"}),e.jsx("input",{type:"checkbox",checked:t.enableNotifications,onChange:s=>n("enableNotifications",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Use native host"}),e.jsx("input",{type:"checkbox",checked:t.useNativeHost,onChange:s=>n("useNativeHost",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Activate app on download"}),e.jsx("input",{type:"checkbox",checked:t.activateAppOnDownload,onChange:s=>n("activateAppOnDownload",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Hide browser download shelf"}),e.jsx("input",{type:"checkbox",checked:t.hideChromeBar,onChange:s=>n("hideChromeBar",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show context menu option"}),e.jsx("input",{type:"checkbox",checked:t.showContextOption,onChange:s=>n("showContextOption",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Download fallback"}),e.jsx("input",{type:"checkbox",checked:t.downloadFallback,onChange:s=>n("downloadFallback",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Dark mode"}),e.jsx("input",{type:"checkbox",checked:t.darkMode,onChange:s=>n("darkMode",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show only aria downloads"}),e.jsx("input",{type:"checkbox",checked:t.showOnlyAria,onChange:s=>n("showOnlyAria",s.target.checked)})]})]})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{onClick:x,children:"Save"}),e.jsx("button",{className:"ghost",onClick:()=>window.close(),children:"Close"})]}),e.jsx("div",{children:h})]}):e.jsx("div",{className:"wrap",children:"Loading..."})}p.createRoot(document.getElementById("root")).render(e.jsx(a.StrictMode,{children:e.jsx(u,{})}));

View File

@@ -0,0 +1 @@
import{c as k,j as t,R as r}from"./client-CBvt1tWS.js";import{b as i}from"./browser-polyfill-CZ_dLIqp.js";import{g as N,s as m}from"./settings-Bo6W9Drl.js";function b(){const[s,d]=r.useState(null),[x,n]=r.useState(""),[l,u]=r.useState([]);r.useEffect(()=>{N().then(d)},[]),r.useEffect(()=>{let e=null;const a=async()=>{const o=await i.runtime.sendMessage({type:"media:list"});o?.ok&&Array.isArray(o.items)&&u(o.items.slice(0,10))};return a(),e=window.setInterval(()=>{a()},2e3),()=>{e!==null&&window.clearInterval(e)}},[]);const c=(e,a)=>{d(o=>o&&{...o,[e]:a})},h=async e=>{if(!s)return;const a={...s,extensionStatus:e};d(a),await m({extensionStatus:e}),n(e?"Extension ON":"Extension OFF"),window.setTimeout(()=>n(""),1200)},p=async()=>{s&&(await m(s),n("Saved"),window.setTimeout(()=>n(""),1200))},g=async()=>{const e=i.runtime.getURL("src/config/index.html");await i.tabs.create({url:e})},j=async()=>{const e=i.runtime.getURL("src/history/index.html");await i.tabs.create({url:e})},v=async()=>{const e=await i.runtime.sendMessage({type:"page:enqueue-ytdlp"});n(e?.ok?"Active tab sent to gdown (yt-dlp)":`Send failed: ${e?.error||"unknown error"}`),window.setTimeout(()=>n(""),1800)},w=async e=>{const a=await i.runtime.sendMessage({type:"media:enqueue",url:e.url,referer:e.referer||""});n(a?.ok?"Media sent to gdown":`Send failed: ${a?.error||"unknown error"}`),window.setTimeout(()=>n(""),1600)},y=async()=>{await i.runtime.sendMessage({type:"media:clear"}),u([]),n("Captured media cleared"),window.setTimeout(()=>n(""),1200)};return s?t.jsxs("div",{className:"container",children:[t.jsx("h1",{children:"Gomdown Helper"}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:"RPC Secret"}),t.jsx("input",{type:"text",value:s.motrixAPIkey,onChange:e=>c("motrixAPIkey",e.target.value),placeholder:"aria2 rpc secret"})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:"RPC Port"}),t.jsx("input",{type:"number",value:s.motrixPort,onChange:e=>c("motrixPort",Number(e.target.value||16800))})]}),t.jsxs("label",{className:"toggle",children:["Extension Enabled",t.jsx("input",{type:"checkbox",checked:s.extensionStatus,onChange:e=>{h(e.target.checked)}})]}),t.jsxs("label",{className:"toggle",children:["Use Native Host",t.jsx("input",{type:"checkbox",checked:s.useNativeHost,onChange:e=>c("useNativeHost",e.target.checked)})]}),t.jsxs("label",{className:"toggle",children:["Activate gdown App",t.jsx("input",{type:"checkbox",checked:s.activateAppOnDownload,onChange:e=>c("activateAppOnDownload",e.target.checked)})]}),t.jsx("button",{onClick:p,children:"Save"}),t.jsx("button",{onClick:g,children:"Settings"}),t.jsx("button",{onClick:j,children:"History"}),t.jsx("button",{onClick:()=>{v()},children:"Send Active Tab (yt-dlp)"}),t.jsxs("div",{className:"media-panel",children:[t.jsxs("div",{className:"media-head",children:[t.jsx("strong",{children:"Captured Media"}),t.jsx("button",{className:"mini ghost",onClick:y,children:"Clear"})]}),l.length===0?t.jsx("div",{className:"empty",children:"No media captured yet"}):t.jsx("div",{className:"media-list",children:l.map(e=>t.jsxs("div",{className:"media-item",children:[t.jsxs("div",{className:"media-meta",children:[t.jsx("span",{className:"kind",children:e.kind.toUpperCase()}),t.jsx("span",{className:"url",children:e.url})]}),t.jsx("button",{className:"mini",onClick:()=>{w(e)},children:"Add"})]},e.id))})]}),t.jsx("div",{className:"status",children:x})]}):t.jsx("div",{className:"container",children:"Loading..."})}k.createRoot(document.getElementById("root")).render(t.jsx(r.StrictMode,{children:t.jsx(b,{})}));

View File

@@ -0,0 +1 @@
import{b as w}from"./browser-polyfill-CZ_dLIqp.js";import{i as o,n as h}from"./downloadIntent-Dv31jC2S.js";const p=8e3,e=new Map;function m(){const r=Date.now();for(const[n,t]of e.entries())t<=r&&e.delete(n)}async function i(r,n){const t=h(r,window.location.href);if(!t)return!1;if(m(),e.has(t))return!0;e.set(t,Date.now()+p);try{if((await w.runtime.sendMessage({type:"capture-link-download",url:t,referer:n||document.referrer||window.location.href}))?.ok)return!0}catch{}return e.delete(t),!1}function u(r){return r?r instanceof HTMLAnchorElement?r:r instanceof Element?r.closest("a[href]"):null:null}function a(r){return!!(r.metaKey||r.ctrlKey||r.shiftKey||r.altKey)}async function d(r){if(r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),await i(t,document.referrer||window.location.href))}function l(r){const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||a(r)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))}document.addEventListener("pointerdown",r=>{r.button===0&&l(r)},!0);document.addEventListener("mousedown",r=>{r.button===0&&l(r)},!0);document.addEventListener("click",r=>{r.button===0&&d(r)},!0);document.addEventListener("keydown",r=>{if(r.key!=="Enter"||r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))},!0);document.addEventListener("auxclick",r=>{r.button===1&&d(r)},!0);function g(){try{const r=window.open.bind(window);window.open=function(t,f,s){const c=String(t||"").trim();return c&&o(c,window.location.href)?(i(c,window.location.href),null):r(t,f,s)}}catch{}try{const r=HTMLAnchorElement.prototype.click;HTMLAnchorElement.prototype.click=function(){const t=this.href||this.getAttribute("href")||"";if(t&&o(t,window.location.href)){i(t,document.referrer||window.location.href);return}r.call(this)}}catch{}}g();

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
(function () {
'use strict';
const injectTime = performance.now();
(async () => {
const { onExecute } = await import(
/* @vite-ignore */
chrome.runtime.getURL("assets/index.ts-BGLNJwsP.js")
);
onExecute?.({ perf: { injectTime, loadTime: performance.now() - injectTime } });
})().catch(console.error);
})();

View File

@@ -0,0 +1 @@
import{b as e}from"./browser-polyfill-CZ_dLIqp.js";const t={extensionStatus:!0,useNativeHost:!0,activateAppOnDownload:!0,enableNotifications:!0,hideChromeBar:!0,showContextOption:!0,downloadFallback:!1,darkMode:!1,showOnlyAria:!1,minFileSize:0,blacklist:[],motrixPort:16800,motrixAPIkey:""};async function n(){const o=await e.storage.sync.get(Object.keys(t));return{extensionStatus:!!(o.extensionStatus??t.extensionStatus),useNativeHost:!!(o.useNativeHost??t.useNativeHost),activateAppOnDownload:!!(o.activateAppOnDownload??t.activateAppOnDownload),enableNotifications:!!(o.enableNotifications??t.enableNotifications),hideChromeBar:!!(o.hideChromeBar??t.hideChromeBar),showContextOption:!!(o.showContextOption??t.showContextOption),downloadFallback:!!(o.downloadFallback??t.downloadFallback),darkMode:!!(o.darkMode??t.darkMode),showOnlyAria:!!(o.showOnlyAria??t.showOnlyAria),minFileSize:Number(o.minFileSize??t.minFileSize),blacklist:Array.isArray(o.blacklist)?o.blacklist.map(a=>String(a)):t.blacklist,motrixPort:Number(o.motrixPort??t.motrixPort),motrixAPIkey:String(o.motrixAPIkey??t.motrixAPIkey)}}async function s(o){await e.storage.sync.set(o)}export{n as g,s};

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,68 @@
{
"manifest_version": 3,
"name": "Gomdown Helper",
"description": "Send browser downloads to gdown",
"version": "0.0.10",
"default_locale": "en",
"icons": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
},
"background": {
"service_worker": "service-worker-loader.js",
"type": "module"
},
"action": {
"default_popup": "src/popup/index.html",
"default_title": "Gomdown Helper",
"default_icon": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
}
},
"options_page": "src/config/index.html",
"content_scripts": [
{
"js": [
"assets/index.ts-loader-DMyyuf2n.js"
],
"matches": [
"<all_urls>"
],
"run_at": "document_start",
"all_frames": true
}
],
"permissions": [
"downloads",
"downloads.shelf",
"notifications",
"storage",
"contextMenus",
"cookies",
"webRequest",
"nativeMessaging"
],
"host_permissions": [
"<all_urls>"
],
"web_accessible_resources": [
{
"matches": [
"<all_urls>"
],
"resources": [
"images/*",
"assets/browser-polyfill-CZ_dLIqp.js",
"assets/downloadIntent-Dv31jC2S.js",
"assets/index.ts-BGLNJwsP.js"
],
"use_dynamic_url": false
}
],
"short_name": "Gomdown"
}

View File

@@ -0,0 +1 @@
import './assets/index.ts-U2ACoZ75.js';

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper Settings</title>
<script type="module" crossorigin src="/assets/index.html-B0Kfv8fq.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-B2D5FcJM.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper</title>
<script type="module" crossorigin src="/assets/index.html-Tb8yZAds.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-D6aWDpYY.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,83 @@
{
"../../../../../@crx/manifest": {
"file": "assets/crx-manifest.js-DthtiGNU.js",
"name": "crx-manifest.js",
"src": "../../../../../@crx/manifest",
"isEntry": true
},
"_browser-polyfill-CZ_dLIqp.js": {
"file": "assets/browser-polyfill-CZ_dLIqp.js",
"name": "browser-polyfill"
},
"_client-CBvt1tWS.js": {
"file": "assets/client-CBvt1tWS.js",
"name": "client",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"_downloadIntent-Dv31jC2S.js": {
"file": "assets/downloadIntent-Dv31jC2S.js",
"name": "downloadIntent"
},
"_index.ts-loader-DMyyuf2n.js": {
"file": "assets/index.ts-loader-DMyyuf2n.js",
"src": "_index.ts-loader-DMyyuf2n.js"
},
"_settings-Bo6W9Drl.js": {
"file": "assets/settings-Bo6W9Drl.js",
"name": "settings",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"src/background/index.ts": {
"file": "assets/index.ts-BnPsJZXz.js",
"name": "index.ts",
"src": "src/background/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js",
"_settings-Bo6W9Drl.js"
]
},
"src/config/index.html": {
"file": "assets/index.html-B0Kfv8fq.js",
"name": "index.html",
"src": "src/config/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_settings-Bo6W9Drl.js",
"_browser-polyfill-CZ_dLIqp.js"
],
"css": [
"assets/index-B2D5FcJM.css"
]
},
"src/content/index.ts": {
"file": "assets/index.ts-BGLNJwsP.js",
"name": "index.ts",
"src": "src/content/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js"
]
},
"src/popup/index.html": {
"file": "assets/index.html-D-JbSuV5.js",
"name": "index.html",
"src": "src/popup/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_browser-polyfill-CZ_dLIqp.js",
"_settings-Bo6W9Drl.js"
],
"css": [
"assets/index-BZvbrf4l.css"
]
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix WebExtension",
"description": "The name of the application"
},
"appShortName": {
"message": "Motrix WebExt",
"description": "The short_name (maximum of 12 characters recommended) is a short version of the app's name."
},
"appDescription": {
"message": "WebExtension for Motrix download manager",
"description": "The description of the application"
},
"browserActionTitle": {
"message": "Motrix WebExtension",
"description": "The title of the browser action button"
},
"extensionStatus": {
"message": "Extension status:",
"description": "Extension status"
},
"enableNotifications": {
"message": "Enable notifications:",
"description": "Enable Notifications"
},
"setKey": {
"message": "Set Key",
"description": "Set Key"
},
"setMinSize": {
"message": "Set minimum file size (mb)",
"description": "Set minimum file size"
},
"setSize": {
"message": "Set size",
"description": "Set size"
},
"keyInputPlaceholder": {
"message": "Motrix API Key",
"description": "Motrix API Key"
},
"blacklist": {
"message": "Blacklist",
"description": "Blacklist"
},
"saveBlacklist": {
"message": "Save blacklist",
"description": "Save blacklist"
},
"darkMode": {
"message": "Dark mode",
"description": "Dark mode"
},
"showOnlyAria": {
"message": "Show only Motrix downloads in the popup",
"description": "Show only Motrix downloads in the popup"
},
"hideChromeBar": {
"message": "Hide chrome download bar",
"description": "Hide chrome download bar"
},
"showContextOption": {
"message": "Show \"Download with gdown\" context option",
"description": "Show \"Download with gdown\" context option"
},
"downloadWithMotrix": {
"message": "Download with gdown",
"description": "Download with gdown"
},
"setPort": {
"message": "Set Port",
"description": "Set Port"
},
"downloadFallback": {
"message": "If launching in gdown fails, use the browser's default download manager",
"description": "If launching in gdown fails, use the browser's default download manager"
},
"useNativeHost": {
"message": "Use Native Messaging host for downloads",
"description": "Use Native Messaging host for downloads"
},
"activateAppOnDownload": {
"message": "Activate gdown app when transfer starts",
"description": "Activate gdown app when transfer starts"
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix 网页扩展",
"description": "应用程序名称"
},
"appShortName": {
"message": "Motrix 扩展",
"description": "应用程序缩略名称"
},
"appDescription": {
"message": "用于 Motrix 下载管理器的网页扩展",
"description": "应用程序描述"
},
"browserActionTitle": {
"message": "Motrix 网页扩展",
"description": "浏览器操作按钮标题"
},
"extensionStatus": {
"message": "扩展状态",
"description": "扩展状态"
},
"enableNotifications": {
"message": "允许桌面通知",
"description": "允许桌面通知"
},
"setKey": {
"message": "设置密钥",
"description": "设置密钥"
},
"setMinSize": {
"message": "设置最小下载文件 (mb)",
"description": "设置最小下载文件"
},
"setSize": {
"message": "设置大小",
"description": "设置大小"
},
"keyInputPlaceholder": {
"message": "Motrix API 密钥",
"description": "Motrix API 密钥"
},
"blacklist": {
"message": "黑名单",
"description": "黑名单"
},
"saveBlacklist": {
"message": "保存黑名单",
"description": "保存黑名单"
},
"darkMode": {
"message": "深色模式",
"description": "深色模式"
},
"showOnlyAria": {
"message": "在弹出窗口中仅显示 Motrix 下载",
"description": "在弹出窗口中仅显示 Motrix 下载"
},
"hideChromeBar": {
"message": "隐藏 Chrome 下载栏",
"description": "隐藏 Chrome 下载栏"
},
"showContextOption": {
"message": "显示“使用 gdown 下载”右键选项",
"description": "显示“使用 gdown 下载”右键选项"
},
"downloadWithMotrix": {
"message": "使用 gdown 下载",
"description": "使用 gdown 下载"
},
"setPort": {
"message": "设置端口",
"description": "设置端口"
},
"downloadFallback": {
"message": "如果 gdown 启动失败,则使用浏览器的默认下载管理器",
"description": "如果 gdown 启动失败,则使用浏览器的默认下载管理器"
},
"useNativeHost": {
"message": "使用 Native Messaging 主机传输下载",
"description": "使用 Native Messaging 主机传输下载"
},
"activateAppOnDownload": {
"message": "下载转交时激活 gdown 应用",
"description": "下载转交时激活 gdown 应用"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
const s=/\.(zip|7z|rar|tar|gz|bz2|xz|dmg|pkg|exe|msi|iso|torrent|pdf|mp4|mkv|mp3|flac|apk|deb|rpm|ipa|img|bin)(?:$|[?#])/i,p=/^(text\/html|text\/plain|application\/json|application\/javascript|application\/xml|text\/xml)/i,d=/(^|\/)(download|downloads|dl|get|file|files|attachment|attachments)(\/|$)/i;function i(n,t){try{return new URL(n,t)}catch{return null}}function w(n,t){const e=i(n,t);return e?e.toString():String(n||"")}function a(n,t){const e=i(n,t);return e?s.test(e.pathname||""):s.test(String(n||""))}function g(n){const t=String(n||"").replace(/-/g,"+").replace(/_/g,"/");try{return atob(t)}catch{return""}}function m(n){if(!d.test(n))return!1;const t=String(n||"").split("/").filter(Boolean),e=t[t.length-1]||"";return!e||e.includes(".")?!1:/^[a-z0-9_-]{12,}$/i.test(e)}function h(n){const t=n.searchParams,e=t.get("golink");if(e){const r=g(e);if(r&&s.test(r))return!0}const o=t.get("filename")||t.get("file")||t.get("name")||t.get("out");return!!(o&&s.test(o)||t.has("attachment")||t.has("download"))}function y(n,t){const e=i(n,t);return!e||!["http:","https:","ftp:"].includes(e.protocol)?!1:!!(a(e.toString())||h(e)||m(e.pathname||""))}function L(n){const t=Array.isArray(n?.responseHeaders)?n.responseHeaders:[],e=l=>{const c=String(l||"").toLowerCase(),u=t.find(f=>String(f?.name||"").toLowerCase()===c);return String(u?.value||"")},o=e("content-disposition").toLowerCase(),r=e("content-type").toLowerCase();return o.includes("attachment")||a(n.url||"")?!0:!r||p.test(r)?!1:r.startsWith("application/")||r.startsWith("audio/")||r.startsWith("video/")}export{L as a,y as i,w as n};

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#141820;color:#e6ebf7}.wrap{max-width:860px;margin:0 auto;padding:24px;display:grid;gap:12px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.card{background:#1f2530;border:1px solid #323b4a;border-radius:10px;padding:12px;display:grid;gap:8px}label{font-size:12px;color:#aeb8cc}input,textarea{border:1px solid #3c4658;border-radius:7px;background:#121721;color:#e6ebf7;padding:8px 10px}input[type=checkbox]{width:16px;height:16px}.row{display:flex;align-items:center;justify-content:space-between;gap:8px}.actions{display:flex;gap:8px}button{border:1px solid #5967f4;background:#5967f4;color:#fff;border-radius:8px;padding:8px 12px;font-weight:600;cursor:pointer}button.ghost{background:#232a36;border-color:#3b4658}@media(max-width:900px){.grid{grid-template-columns:1fr}}

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#151821;color:#e7ebf7;width:360px}.container{padding:14px;display:grid;gap:10px}h1{margin:0;font-size:14px}.field{display:grid;gap:6px}label{font-size:12px;color:#aeb6cc}input[type=text],input[type=number]{height:32px;border:1px solid #3e4658;border-radius:6px;padding:0 10px;background:#202532;color:#e7ebf7}.toggle{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:#cdd5ea}button{height:34px;border:1px solid #5562f0;border-radius:8px;background:#5562f0;color:#fff;font-weight:600;cursor:pointer}.status{font-size:12px;color:#8fe0a6;min-height:14px}

View File

@@ -0,0 +1,3 @@
import{c as p,j as e,R as a}from"./client-CBvt1tWS.js";import{g as j,s as m}from"./settings-Bo6W9Drl.js";import"./browser-polyfill-CZ_dLIqp.js";function u(){const[t,i]=a.useState(null),[l,r]=a.useState(""),[h,d]=a.useState("");a.useEffect(()=>{j().then(s=>{i(s),r((s.blacklist||[]).join(`
`))})},[]);const n=(s,c)=>{i(o=>o&&{...o,[s]:c})},x=async()=>{if(!t)return;const s={...t,minFileSize:Number(t.minFileSize||0),motrixPort:Number(t.motrixPort||16800),blacklist:l.split(`
`).map(c=>c.trim()).filter(Boolean)};await m(s),i(s),d("Saved"),window.setTimeout(()=>d(""),1500)};return t?e.jsxs("div",{className:"wrap",children:[e.jsx("h1",{children:"Gomdown Helper Settings"}),e.jsxs("div",{className:"grid",children:[e.jsxs("section",{className:"card",children:[e.jsx("label",{children:"RPC Secret"}),e.jsx("input",{value:t.motrixAPIkey,onChange:s=>n("motrixAPIkey",s.target.value)}),e.jsx("label",{children:"RPC Port"}),e.jsx("input",{type:"number",value:t.motrixPort,onChange:s=>n("motrixPort",Number(s.target.value||16800))}),e.jsx("label",{children:"Min file size (MB)"}),e.jsx("input",{type:"number",value:t.minFileSize,onChange:s=>n("minFileSize",Number(s.target.value||0))}),e.jsx("label",{children:"Blacklist (one per line)"}),e.jsx("textarea",{rows:8,value:l,onChange:s=>r(s.target.value)})]}),e.jsxs("section",{className:"card",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Extension enabled"}),e.jsx("input",{type:"checkbox",checked:t.extensionStatus,onChange:s=>n("extensionStatus",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Enable notifications"}),e.jsx("input",{type:"checkbox",checked:t.enableNotifications,onChange:s=>n("enableNotifications",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Use native host"}),e.jsx("input",{type:"checkbox",checked:t.useNativeHost,onChange:s=>n("useNativeHost",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Activate app on download"}),e.jsx("input",{type:"checkbox",checked:t.activateAppOnDownload,onChange:s=>n("activateAppOnDownload",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Hide browser download shelf"}),e.jsx("input",{type:"checkbox",checked:t.hideChromeBar,onChange:s=>n("hideChromeBar",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show context menu option"}),e.jsx("input",{type:"checkbox",checked:t.showContextOption,onChange:s=>n("showContextOption",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Download fallback"}),e.jsx("input",{type:"checkbox",checked:t.downloadFallback,onChange:s=>n("downloadFallback",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Dark mode"}),e.jsx("input",{type:"checkbox",checked:t.darkMode,onChange:s=>n("darkMode",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show only aria downloads"}),e.jsx("input",{type:"checkbox",checked:t.showOnlyAria,onChange:s=>n("showOnlyAria",s.target.checked)})]})]})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{onClick:x,children:"Save"}),e.jsx("button",{className:"ghost",onClick:()=>window.close(),children:"Close"})]}),e.jsx("div",{children:h})]}):e.jsx("div",{className:"wrap",children:"Loading..."})}p.createRoot(document.getElementById("root")).render(e.jsx(a.StrictMode,{children:e.jsx(u,{})}));

View File

@@ -0,0 +1 @@
import{c as g,j as e,R as c}from"./client-CBvt1tWS.js";import{b as a}from"./browser-polyfill-CZ_dLIqp.js";import{g as m,s as p}from"./settings-Bo6W9Drl.js";function j(){const[s,o]=c.useState(null),[l,r]=c.useState("");c.useEffect(()=>{m().then(o)},[]);const n=(t,h)=>{o(i=>i&&{...i,[t]:h})},d=async()=>{s&&(await p(s),r("Saved"),window.setTimeout(()=>r(""),1200))},u=async()=>{const t=a.runtime.getURL("src/config/index.html");await a.tabs.create({url:t})},x=async()=>{const t=a.runtime.getURL("src/history/index.html");await a.tabs.create({url:t})};return s?e.jsxs("div",{className:"container",children:[e.jsx("h1",{children:"Gomdown Helper"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"RPC Secret"}),e.jsx("input",{type:"text",value:s.motrixAPIkey,onChange:t=>n("motrixAPIkey",t.target.value),placeholder:"aria2 rpc secret"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"RPC Port"}),e.jsx("input",{type:"number",value:s.motrixPort,onChange:t=>n("motrixPort",Number(t.target.value||16800))})]}),e.jsxs("label",{className:"toggle",children:["Extension Enabled",e.jsx("input",{type:"checkbox",checked:s.extensionStatus,onChange:t=>n("extensionStatus",t.target.checked)})]}),e.jsxs("label",{className:"toggle",children:["Use Native Host",e.jsx("input",{type:"checkbox",checked:s.useNativeHost,onChange:t=>n("useNativeHost",t.target.checked)})]}),e.jsxs("label",{className:"toggle",children:["Activate gdown App",e.jsx("input",{type:"checkbox",checked:s.activateAppOnDownload,onChange:t=>n("activateAppOnDownload",t.target.checked)})]}),e.jsx("button",{onClick:d,children:"Save"}),e.jsx("button",{onClick:u,children:"Settings"}),e.jsx("button",{onClick:x,children:"History"}),e.jsx("div",{className:"status",children:l})]}):e.jsx("div",{className:"container",children:"Loading..."})}g.createRoot(document.getElementById("root")).render(e.jsx(c.StrictMode,{children:e.jsx(j,{})}));

View File

@@ -0,0 +1 @@
import{b as w}from"./browser-polyfill-CZ_dLIqp.js";import{i as o,n as h}from"./downloadIntent-Dv31jC2S.js";const p=8e3,e=new Map;function m(){const r=Date.now();for(const[n,t]of e.entries())t<=r&&e.delete(n)}async function i(r,n){const t=h(r,window.location.href);if(!t)return!1;if(m(),e.has(t))return!0;e.set(t,Date.now()+p);try{if((await w.runtime.sendMessage({type:"capture-link-download",url:t,referer:n||document.referrer||window.location.href}))?.ok)return!0}catch{}return e.delete(t),!1}function u(r){return r?r instanceof HTMLAnchorElement?r:r instanceof Element?r.closest("a[href]"):null:null}function a(r){return!!(r.metaKey||r.ctrlKey||r.shiftKey||r.altKey)}async function d(r){if(r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),await i(t,document.referrer||window.location.href))}function l(r){const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||a(r)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))}document.addEventListener("pointerdown",r=>{r.button===0&&l(r)},!0);document.addEventListener("mousedown",r=>{r.button===0&&l(r)},!0);document.addEventListener("click",r=>{r.button===0&&d(r)},!0);document.addEventListener("keydown",r=>{if(r.key!=="Enter"||r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))},!0);document.addEventListener("auxclick",r=>{r.button===1&&d(r)},!0);function g(){try{const r=window.open.bind(window);window.open=function(t,f,s){const c=String(t||"").trim();return c&&o(c,window.location.href)?(i(c,window.location.href),null):r(t,f,s)}}catch{}try{const r=HTMLAnchorElement.prototype.click;HTMLAnchorElement.prototype.click=function(){const t=this.href||this.getAttribute("href")||"";if(t&&o(t,window.location.href)){i(t,document.referrer||window.location.href);return}r.call(this)}}catch{}}g();

View File

@@ -0,0 +1 @@
import{b as r}from"./browser-polyfill-CZ_dLIqp.js";import{n as v,a as k}from"./downloadIntent-Dv31jC2S.js";import{g as d}from"./settings-Bo6W9Drl.js";const C="org.gdown.nativehost";async function L(e){return r.runtime.sendNativeMessage(C,{action:"addUri",...e})}async function I(){return r.runtime.sendNativeMessage(C,{action:"focus"})}const p="history";async function H(){const t=(await r.storage.local.get([p]))[p];return Array.isArray(t)?t:[]}async function M(e){await r.storage.local.set({[p]:e.slice(0,300)})}async function T(e){const t=await H(),n=t.findIndex(o=>o.gid===e.gid);n>=0?t[n]=e:t.unshift(e),await M(t)}const y=8e3,A=7e3,D="gomdown-helper-download-context-menu-option",c=new Map,w=new Map,g=new Map,m=new Map,a=new Map,h=new Map;function l(e){try{const t=new URL(e),n=(t.pathname||"/").replace(/\/+$/,"")||"/";return`${t.protocol}//${t.host}${n}`.toLowerCase()}catch{return String(e||"").toLowerCase()}}function i(e){const t=Date.now();for(const[n,o]of e.entries())o<=t&&e.delete(n)}function R(e){const t=Date.now()+y;w.set(v(e),t),g.set(l(e),t)}function q(e){!Number.isInteger(e)||(e??-1)<0||h.set(e,Date.now()+y)}function N(e){i(w),i(g);const t=v(e);return w.has(t)||g.has(l(e))}function _(e){return i(h),!Number.isInteger(e)||(e??-1)<0?!1:h.has(e)}function E(e){return i(m),m.has(l(e))}function F(e){m.set(l(e),Date.now()+A)}function O(e){return i(a),!!e&&a.has(e)}function P(e){e&&a.set(e,Date.now()+y)}async function $(){try{await I()}catch{}}async function S(e,t=""){if(E(e))return{ok:!1,error:"duplicate transfer suppressed"};const n=await d();if(!n.extensionStatus)return{ok:!1,error:"extension disabled"};if(!n.motrixAPIkey)return{ok:!1,error:"motrixAPIkey is not set"};try{const o=await L({url:e,rpcPort:n.motrixPort,rpcSecret:n.motrixAPIkey,referer:t,split:64});if(!o?.ok)return{ok:!1,error:o?.error||"native host addUri failed"};n.activateAppOnDownload&&await $(),F(e);const s=String(o?.gid||o?.requestId||`pending-${Date.now()}`),U=(()=>{try{return new URL(e).pathname}catch{return""}})().split("/").filter(Boolean).pop()||e;return await T({gid:s,downloader:"native",startTime:new Date().toISOString(),icon:"/images/32.png",name:decodeURIComponent(U),path:null,status:o?.pending?"queued":"downloading",size:0,downloaded:0}),n.enableNotifications&&await r.notifications.create(`gomdown-transfer-${Date.now()}`,{type:"basic",iconUrl:"/images/icon-large.png",title:"Gomdown Helper",message:"Download sent to gdown"}),{ok:!0}}catch(o){return{ok:!1,error:String(o)}}}async function z(e){if(e.type!=="main_frame"||(e.method||"").toUpperCase()!=="GET"||typeof e.statusCode=="number"&&(e.statusCode<200||e.statusCode>299))return!1;const t=await d();if(!t.extensionStatus||!t.motrixAPIkey)return!1;const n=String(Array.isArray(e?.responseHeaders)&&e.responseHeaders.find(s=>String(s?.name||"").toLowerCase()==="content-length")?.value||""),o=Number(n||0);return t.minFileSize>0&&o>0&&o<t.minFileSize*1024*1024?!1:k(e)}async function G(e){if(O(e.requestId)||!await z(e))return;const n=c.get(e.requestId),o=String(n?.documentUrl||n?.originUrl||n?.initiator||n?.url||"");(await S(e.url,o)).ok&&(P(e.requestId),R(e.url),q(e.tabId))}async function u(){const e=r.downloads;if(!e.setShelfEnabled)return;const t=await d();if(!t.extensionStatus)return;const n=t.useNativeHost?!1:!t.hideChromeBar;await e.setShelfEnabled(n)}function b(){r.downloads.onCreated.addListener(async e=>{await u();const t=e,n=t.finalUrl||t.url||"";!N(n)&&!_(t.tabId)||(await r.downloads.cancel(e.id).catch(()=>null),await r.downloads.erase({id:e.id}).catch(()=>null),await r.downloads.removeFile(e.id).catch(()=>null))})}function x(){r.webRequest.onSendHeaders.addListener(e=>{c.set(e.requestId,e)},{urls:["<all_urls>"]},["requestHeaders","extraHeaders"]),r.webRequest.onErrorOccurred.addListener(e=>{c.delete(e.requestId),a.delete(String(e.requestId))},{urls:["<all_urls>"]}),r.webRequest.onCompleted.addListener(e=>{c.delete(e.requestId),a.delete(String(e.requestId))},{urls:["<all_urls>"]}),r.webRequest.onHeadersReceived.addListener(e=>{G(e)},{urls:["<all_urls>"]},["responseHeaders"])}function f(){r.contextMenus.removeAll().then(async()=>{const e=await d();e.showContextOption&&r.contextMenus.create({id:D,title:"Download with Gomdown",visible:e.showContextOption,contexts:["all"]})}),r.contextMenus.onClicked.addListener(async e=>{const t=e.linkUrl||e.srcUrl||e.pageUrl;t&&await S(t)})}r.runtime.onMessage.addListener((e,t)=>{if(e?.type!=="capture-link-download")return;const n=String(e?.url||"").trim();if(!n)return Promise.resolve({ok:!1,error:"url is empty"});const o=Number(t?.tab?.id);return S(n,String(e?.referer||"")).then(s=>(s.ok&&(R(n),q(o)),s))});r.runtime.onInstalled.addListener(()=>{x(),b(),f(),u()});r.runtime.onStartup.addListener(()=>{x(),b(),f(),u()});r.storage.onChanged.addListener((e,t)=>{t==="sync"&&((e.hideChromeBar||e.useNativeHost||e.extensionStatus)&&u(),e.showContextOption&&f())});x();b();f();u();

View File

@@ -0,0 +1,13 @@
(function () {
'use strict';
const injectTime = performance.now();
(async () => {
const { onExecute } = await import(
/* @vite-ignore */
chrome.runtime.getURL("assets/index.ts-BGLNJwsP.js")
);
onExecute?.({ perf: { injectTime, loadTime: performance.now() - injectTime } });
})().catch(console.error);
})();

View File

@@ -0,0 +1 @@
import{b as e}from"./browser-polyfill-CZ_dLIqp.js";const t={extensionStatus:!0,useNativeHost:!0,activateAppOnDownload:!0,enableNotifications:!0,hideChromeBar:!0,showContextOption:!0,downloadFallback:!1,darkMode:!1,showOnlyAria:!1,minFileSize:0,blacklist:[],motrixPort:16800,motrixAPIkey:""};async function n(){const o=await e.storage.sync.get(Object.keys(t));return{extensionStatus:!!(o.extensionStatus??t.extensionStatus),useNativeHost:!!(o.useNativeHost??t.useNativeHost),activateAppOnDownload:!!(o.activateAppOnDownload??t.activateAppOnDownload),enableNotifications:!!(o.enableNotifications??t.enableNotifications),hideChromeBar:!!(o.hideChromeBar??t.hideChromeBar),showContextOption:!!(o.showContextOption??t.showContextOption),downloadFallback:!!(o.downloadFallback??t.downloadFallback),darkMode:!!(o.darkMode??t.darkMode),showOnlyAria:!!(o.showOnlyAria??t.showOnlyAria),minFileSize:Number(o.minFileSize??t.minFileSize),blacklist:Array.isArray(o.blacklist)?o.blacklist.map(a=>String(a)):t.blacklist,motrixPort:Number(o.motrixPort??t.motrixPort),motrixAPIkey:String(o.motrixAPIkey??t.motrixAPIkey)}}async function s(o){await e.storage.sync.set(o)}export{n as g,s};

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
packages/edge/images/16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

BIN
packages/edge/images/32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
packages/edge/images/48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,68 @@
{
"manifest_version": 3,
"name": "Gomdown Helper",
"description": "Send browser downloads to gdown",
"version": "0.0.1",
"default_locale": "en",
"icons": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
},
"background": {
"service_worker": "service-worker-loader.js",
"type": "module"
},
"action": {
"default_popup": "src/popup/index.html",
"default_title": "Gomdown Helper",
"default_icon": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
}
},
"options_page": "src/config/index.html",
"content_scripts": [
{
"js": [
"assets/index.ts-loader-DMyyuf2n.js"
],
"matches": [
"<all_urls>"
],
"run_at": "document_start",
"all_frames": true
}
],
"permissions": [
"downloads",
"downloads.shelf",
"notifications",
"storage",
"contextMenus",
"cookies",
"webRequest",
"nativeMessaging"
],
"host_permissions": [
"<all_urls>"
],
"web_accessible_resources": [
{
"matches": [
"<all_urls>"
],
"resources": [
"images/*",
"assets/browser-polyfill-CZ_dLIqp.js",
"assets/downloadIntent-Dv31jC2S.js",
"assets/index.ts-BGLNJwsP.js"
],
"use_dynamic_url": false
}
],
"short_name": "Gomdown"
}

View File

@@ -0,0 +1 @@
import './assets/index.ts-BnPsJZXz.js';

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper Settings</title>
<script type="module" crossorigin src="/assets/index.html-B0Kfv8fq.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-B2D5FcJM.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper</title>
<script type="module" crossorigin src="/assets/index.html-D-JbSuV5.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-BZvbrf4l.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,83 @@
{
"../../../../../@crx/manifest": {
"file": "assets/crx-manifest.js-DthtiGNU.js",
"name": "crx-manifest.js",
"src": "../../../../../@crx/manifest",
"isEntry": true
},
"_browser-polyfill-CZ_dLIqp.js": {
"file": "assets/browser-polyfill-CZ_dLIqp.js",
"name": "browser-polyfill"
},
"_client-CBvt1tWS.js": {
"file": "assets/client-CBvt1tWS.js",
"name": "client",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"_downloadIntent-Dv31jC2S.js": {
"file": "assets/downloadIntent-Dv31jC2S.js",
"name": "downloadIntent"
},
"_index.ts-loader-DMyyuf2n.js": {
"file": "assets/index.ts-loader-DMyyuf2n.js",
"src": "_index.ts-loader-DMyyuf2n.js"
},
"_settings-Bo6W9Drl.js": {
"file": "assets/settings-Bo6W9Drl.js",
"name": "settings",
"imports": [
"_browser-polyfill-CZ_dLIqp.js"
]
},
"src/background/index.ts": {
"file": "assets/index.ts-BnPsJZXz.js",
"name": "index.ts",
"src": "src/background/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js",
"_settings-Bo6W9Drl.js"
]
},
"src/config/index.html": {
"file": "assets/index.html-B0Kfv8fq.js",
"name": "index.html",
"src": "src/config/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_settings-Bo6W9Drl.js",
"_browser-polyfill-CZ_dLIqp.js"
],
"css": [
"assets/index-B2D5FcJM.css"
]
},
"src/content/index.ts": {
"file": "assets/index.ts-BGLNJwsP.js",
"name": "index.ts",
"src": "src/content/index.ts",
"isEntry": true,
"imports": [
"_browser-polyfill-CZ_dLIqp.js",
"_downloadIntent-Dv31jC2S.js"
]
},
"src/popup/index.html": {
"file": "assets/index.html-D-JbSuV5.js",
"name": "index.html",
"src": "src/popup/index.html",
"isEntry": true,
"imports": [
"_client-CBvt1tWS.js",
"_browser-polyfill-CZ_dLIqp.js",
"_settings-Bo6W9Drl.js"
],
"css": [
"assets/index-BZvbrf4l.css"
]
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix WebExtension",
"description": "The name of the application"
},
"appShortName": {
"message": "Motrix WebExt",
"description": "The short_name (maximum of 12 characters recommended) is a short version of the app's name."
},
"appDescription": {
"message": "WebExtension for Motrix download manager",
"description": "The description of the application"
},
"browserActionTitle": {
"message": "Motrix WebExtension",
"description": "The title of the browser action button"
},
"extensionStatus": {
"message": "Extension status:",
"description": "Extension status"
},
"enableNotifications": {
"message": "Enable notifications:",
"description": "Enable Notifications"
},
"setKey": {
"message": "Set Key",
"description": "Set Key"
},
"setMinSize": {
"message": "Set minimum file size (mb)",
"description": "Set minimum file size"
},
"setSize": {
"message": "Set size",
"description": "Set size"
},
"keyInputPlaceholder": {
"message": "Motrix API Key",
"description": "Motrix API Key"
},
"blacklist": {
"message": "Blacklist",
"description": "Blacklist"
},
"saveBlacklist": {
"message": "Save blacklist",
"description": "Save blacklist"
},
"darkMode": {
"message": "Dark mode",
"description": "Dark mode"
},
"showOnlyAria": {
"message": "Show only Motrix downloads in the popup",
"description": "Show only Motrix downloads in the popup"
},
"hideChromeBar": {
"message": "Hide chrome download bar",
"description": "Hide chrome download bar"
},
"showContextOption": {
"message": "Show \"Download with gdown\" context option",
"description": "Show \"Download with gdown\" context option"
},
"downloadWithMotrix": {
"message": "Download with gdown",
"description": "Download with gdown"
},
"setPort": {
"message": "Set Port",
"description": "Set Port"
},
"downloadFallback": {
"message": "If launching in gdown fails, use the browser's default download manager",
"description": "If launching in gdown fails, use the browser's default download manager"
},
"useNativeHost": {
"message": "Use Native Messaging host for downloads",
"description": "Use Native Messaging host for downloads"
},
"activateAppOnDownload": {
"message": "Activate gdown app when transfer starts",
"description": "Activate gdown app when transfer starts"
}
}

View File

@@ -0,0 +1,86 @@
{
"appName": {
"message": "Motrix 网页扩展",
"description": "应用程序名称"
},
"appShortName": {
"message": "Motrix 扩展",
"description": "应用程序缩略名称"
},
"appDescription": {
"message": "用于 Motrix 下载管理器的网页扩展",
"description": "应用程序描述"
},
"browserActionTitle": {
"message": "Motrix 网页扩展",
"description": "浏览器操作按钮标题"
},
"extensionStatus": {
"message": "扩展状态",
"description": "扩展状态"
},
"enableNotifications": {
"message": "允许桌面通知",
"description": "允许桌面通知"
},
"setKey": {
"message": "设置密钥",
"description": "设置密钥"
},
"setMinSize": {
"message": "设置最小下载文件 (mb)",
"description": "设置最小下载文件"
},
"setSize": {
"message": "设置大小",
"description": "设置大小"
},
"keyInputPlaceholder": {
"message": "Motrix API 密钥",
"description": "Motrix API 密钥"
},
"blacklist": {
"message": "黑名单",
"description": "黑名单"
},
"saveBlacklist": {
"message": "保存黑名单",
"description": "保存黑名单"
},
"darkMode": {
"message": "深色模式",
"description": "深色模式"
},
"showOnlyAria": {
"message": "在弹出窗口中仅显示 Motrix 下载",
"description": "在弹出窗口中仅显示 Motrix 下载"
},
"hideChromeBar": {
"message": "隐藏 Chrome 下载栏",
"description": "隐藏 Chrome 下载栏"
},
"showContextOption": {
"message": "显示“使用 gdown 下载”右键选项",
"description": "显示“使用 gdown 下载”右键选项"
},
"downloadWithMotrix": {
"message": "使用 gdown 下载",
"description": "使用 gdown 下载"
},
"setPort": {
"message": "设置端口",
"description": "设置端口"
},
"downloadFallback": {
"message": "如果 gdown 启动失败,则使用浏览器的默认下载管理器",
"description": "如果 gdown 启动失败,则使用浏览器的默认下载管理器"
},
"useNativeHost": {
"message": "使用 Native Messaging 主机传输下载",
"description": "使用 Native Messaging 主机传输下载"
},
"activateAppOnDownload": {
"message": "下载转交时激活 gdown 应用",
"description": "下载转交时激活 gdown 应用"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
const s=/\.(zip|7z|rar|tar|gz|bz2|xz|dmg|pkg|exe|msi|iso|torrent|pdf|mp4|mkv|mp3|flac|apk|deb|rpm|ipa|img|bin)(?:$|[?#])/i,p=/^(text\/html|text\/plain|application\/json|application\/javascript|application\/xml|text\/xml)/i,d=/(^|\/)(download|downloads|dl|get|file|files|attachment|attachments)(\/|$)/i;function i(n,t){try{return new URL(n,t)}catch{return null}}function w(n,t){const e=i(n,t);return e?e.toString():String(n||"")}function a(n,t){const e=i(n,t);return e?s.test(e.pathname||""):s.test(String(n||""))}function g(n){const t=String(n||"").replace(/-/g,"+").replace(/_/g,"/");try{return atob(t)}catch{return""}}function m(n){if(!d.test(n))return!1;const t=String(n||"").split("/").filter(Boolean),e=t[t.length-1]||"";return!e||e.includes(".")?!1:/^[a-z0-9_-]{12,}$/i.test(e)}function h(n){const t=n.searchParams,e=t.get("golink");if(e){const r=g(e);if(r&&s.test(r))return!0}const o=t.get("filename")||t.get("file")||t.get("name")||t.get("out");return!!(o&&s.test(o)||t.has("attachment")||t.has("download"))}function y(n,t){const e=i(n,t);return!e||!["http:","https:","ftp:"].includes(e.protocol)?!1:!!(a(e.toString())||h(e)||m(e.pathname||""))}function L(n){const t=Array.isArray(n?.responseHeaders)?n.responseHeaders:[],e=l=>{const c=String(l||"").toLowerCase(),u=t.find(f=>String(f?.name||"").toLowerCase()===c);return String(u?.value||"")},o=e("content-disposition").toLowerCase(),r=e("content-type").toLowerCase();return o.includes("attachment")||a(n.url||"")?!0:!r||p.test(r)?!1:r.startsWith("application/")||r.startsWith("audio/")||r.startsWith("video/")}export{L as a,y as i,w as n};

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#141820;color:#e6ebf7}.wrap{max-width:860px;margin:0 auto;padding:24px;display:grid;gap:12px}.grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.card{background:#1f2530;border:1px solid #323b4a;border-radius:10px;padding:12px;display:grid;gap:8px}label{font-size:12px;color:#aeb8cc}input,textarea{border:1px solid #3c4658;border-radius:7px;background:#121721;color:#e6ebf7;padding:8px 10px}input[type=checkbox]{width:16px;height:16px}.row{display:flex;align-items:center;justify-content:space-between;gap:8px}.actions{display:flex;gap:8px}button{border:1px solid #5967f4;background:#5967f4;color:#fff;border-radius:8px;padding:8px 12px;font-weight:600;cursor:pointer}button.ghost{background:#232a36;border-color:#3b4658}@media(max-width:900px){.grid{grid-template-columns:1fr}}

View File

@@ -0,0 +1 @@
:root{color-scheme:dark;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}body{margin:0;background:#151821;color:#e7ebf7;width:360px}.container{padding:14px;display:grid;gap:10px}h1{margin:0;font-size:14px}.field{display:grid;gap:6px}label{font-size:12px;color:#aeb6cc}input[type=text],input[type=number]{height:32px;border:1px solid #3e4658;border-radius:6px;padding:0 10px;background:#202532;color:#e7ebf7}.toggle{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:#cdd5ea}button{height:34px;border:1px solid #5562f0;border-radius:8px;background:#5562f0;color:#fff;font-weight:600;cursor:pointer}.status{font-size:12px;color:#8fe0a6;min-height:14px}

View File

@@ -0,0 +1,3 @@
import{c as p,j as e,R as a}from"./client-CBvt1tWS.js";import{g as j,s as m}from"./settings-Bo6W9Drl.js";import"./browser-polyfill-CZ_dLIqp.js";function u(){const[t,i]=a.useState(null),[l,r]=a.useState(""),[h,d]=a.useState("");a.useEffect(()=>{j().then(s=>{i(s),r((s.blacklist||[]).join(`
`))})},[]);const n=(s,c)=>{i(o=>o&&{...o,[s]:c})},x=async()=>{if(!t)return;const s={...t,minFileSize:Number(t.minFileSize||0),motrixPort:Number(t.motrixPort||16800),blacklist:l.split(`
`).map(c=>c.trim()).filter(Boolean)};await m(s),i(s),d("Saved"),window.setTimeout(()=>d(""),1500)};return t?e.jsxs("div",{className:"wrap",children:[e.jsx("h1",{children:"Gomdown Helper Settings"}),e.jsxs("div",{className:"grid",children:[e.jsxs("section",{className:"card",children:[e.jsx("label",{children:"RPC Secret"}),e.jsx("input",{value:t.motrixAPIkey,onChange:s=>n("motrixAPIkey",s.target.value)}),e.jsx("label",{children:"RPC Port"}),e.jsx("input",{type:"number",value:t.motrixPort,onChange:s=>n("motrixPort",Number(s.target.value||16800))}),e.jsx("label",{children:"Min file size (MB)"}),e.jsx("input",{type:"number",value:t.minFileSize,onChange:s=>n("minFileSize",Number(s.target.value||0))}),e.jsx("label",{children:"Blacklist (one per line)"}),e.jsx("textarea",{rows:8,value:l,onChange:s=>r(s.target.value)})]}),e.jsxs("section",{className:"card",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Extension enabled"}),e.jsx("input",{type:"checkbox",checked:t.extensionStatus,onChange:s=>n("extensionStatus",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Enable notifications"}),e.jsx("input",{type:"checkbox",checked:t.enableNotifications,onChange:s=>n("enableNotifications",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Use native host"}),e.jsx("input",{type:"checkbox",checked:t.useNativeHost,onChange:s=>n("useNativeHost",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Activate app on download"}),e.jsx("input",{type:"checkbox",checked:t.activateAppOnDownload,onChange:s=>n("activateAppOnDownload",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Hide browser download shelf"}),e.jsx("input",{type:"checkbox",checked:t.hideChromeBar,onChange:s=>n("hideChromeBar",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show context menu option"}),e.jsx("input",{type:"checkbox",checked:t.showContextOption,onChange:s=>n("showContextOption",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Download fallback"}),e.jsx("input",{type:"checkbox",checked:t.downloadFallback,onChange:s=>n("downloadFallback",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Dark mode"}),e.jsx("input",{type:"checkbox",checked:t.darkMode,onChange:s=>n("darkMode",s.target.checked)})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{children:"Show only aria downloads"}),e.jsx("input",{type:"checkbox",checked:t.showOnlyAria,onChange:s=>n("showOnlyAria",s.target.checked)})]})]})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{onClick:x,children:"Save"}),e.jsx("button",{className:"ghost",onClick:()=>window.close(),children:"Close"})]}),e.jsx("div",{children:h})]}):e.jsx("div",{className:"wrap",children:"Loading..."})}p.createRoot(document.getElementById("root")).render(e.jsx(a.StrictMode,{children:e.jsx(u,{})}));

View File

@@ -0,0 +1 @@
import{c as g,j as e,R as c}from"./client-CBvt1tWS.js";import{b as a}from"./browser-polyfill-CZ_dLIqp.js";import{g as m,s as p}from"./settings-Bo6W9Drl.js";function j(){const[s,o]=c.useState(null),[l,r]=c.useState("");c.useEffect(()=>{m().then(o)},[]);const n=(t,h)=>{o(i=>i&&{...i,[t]:h})},d=async()=>{s&&(await p(s),r("Saved"),window.setTimeout(()=>r(""),1200))},u=async()=>{const t=a.runtime.getURL("src/config/index.html");await a.tabs.create({url:t})},x=async()=>{const t=a.runtime.getURL("src/history/index.html");await a.tabs.create({url:t})};return s?e.jsxs("div",{className:"container",children:[e.jsx("h1",{children:"Gomdown Helper"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"RPC Secret"}),e.jsx("input",{type:"text",value:s.motrixAPIkey,onChange:t=>n("motrixAPIkey",t.target.value),placeholder:"aria2 rpc secret"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"RPC Port"}),e.jsx("input",{type:"number",value:s.motrixPort,onChange:t=>n("motrixPort",Number(t.target.value||16800))})]}),e.jsxs("label",{className:"toggle",children:["Extension Enabled",e.jsx("input",{type:"checkbox",checked:s.extensionStatus,onChange:t=>n("extensionStatus",t.target.checked)})]}),e.jsxs("label",{className:"toggle",children:["Use Native Host",e.jsx("input",{type:"checkbox",checked:s.useNativeHost,onChange:t=>n("useNativeHost",t.target.checked)})]}),e.jsxs("label",{className:"toggle",children:["Activate gdown App",e.jsx("input",{type:"checkbox",checked:s.activateAppOnDownload,onChange:t=>n("activateAppOnDownload",t.target.checked)})]}),e.jsx("button",{onClick:d,children:"Save"}),e.jsx("button",{onClick:u,children:"Settings"}),e.jsx("button",{onClick:x,children:"History"}),e.jsx("div",{className:"status",children:l})]}):e.jsx("div",{className:"container",children:"Loading..."})}g.createRoot(document.getElementById("root")).render(e.jsx(c.StrictMode,{children:e.jsx(j,{})}));

View File

@@ -0,0 +1 @@
import{b as w}from"./browser-polyfill-CZ_dLIqp.js";import{i as o,n as h}from"./downloadIntent-Dv31jC2S.js";const p=8e3,e=new Map;function m(){const r=Date.now();for(const[n,t]of e.entries())t<=r&&e.delete(n)}async function i(r,n){const t=h(r,window.location.href);if(!t)return!1;if(m(),e.has(t))return!0;e.set(t,Date.now()+p);try{if((await w.runtime.sendMessage({type:"capture-link-download",url:t,referer:n||document.referrer||window.location.href}))?.ok)return!0}catch{}return e.delete(t),!1}function u(r){return r?r instanceof HTMLAnchorElement?r:r instanceof Element?r.closest("a[href]"):null:null}function a(r){return!!(r.metaKey||r.ctrlKey||r.shiftKey||r.altKey)}async function d(r){if(r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),await i(t,document.referrer||window.location.href))}function l(r){const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||a(r)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))}document.addEventListener("pointerdown",r=>{r.button===0&&l(r)},!0);document.addEventListener("mousedown",r=>{r.button===0&&l(r)},!0);document.addEventListener("click",r=>{r.button===0&&d(r)},!0);document.addEventListener("keydown",r=>{if(r.key!=="Enter"||r.defaultPrevented||a(r))return;const n=u(r.target);if(!n)return;const t=n.href||"";!t||!o(t,window.location.href)||(r.preventDefault(),r.stopImmediatePropagation(),r.stopPropagation(),i(t,document.referrer||window.location.href))},!0);document.addEventListener("auxclick",r=>{r.button===1&&d(r)},!0);function g(){try{const r=window.open.bind(window);window.open=function(t,f,s){const c=String(t||"").trim();return c&&o(c,window.location.href)?(i(c,window.location.href),null):r(t,f,s)}}catch{}try{const r=HTMLAnchorElement.prototype.click;HTMLAnchorElement.prototype.click=function(){const t=this.href||this.getAttribute("href")||"";if(t&&o(t,window.location.href)){i(t,document.referrer||window.location.href);return}r.call(this)}}catch{}}g();

View File

@@ -0,0 +1 @@
import{b as r}from"./browser-polyfill-CZ_dLIqp.js";import{n as v,a as k}from"./downloadIntent-Dv31jC2S.js";import{g as d}from"./settings-Bo6W9Drl.js";const C="org.gdown.nativehost";async function L(e){return r.runtime.sendNativeMessage(C,{action:"addUri",...e})}async function I(){return r.runtime.sendNativeMessage(C,{action:"focus"})}const p="history";async function H(){const t=(await r.storage.local.get([p]))[p];return Array.isArray(t)?t:[]}async function M(e){await r.storage.local.set({[p]:e.slice(0,300)})}async function T(e){const t=await H(),n=t.findIndex(o=>o.gid===e.gid);n>=0?t[n]=e:t.unshift(e),await M(t)}const y=8e3,A=7e3,D="gomdown-helper-download-context-menu-option",c=new Map,w=new Map,g=new Map,m=new Map,a=new Map,h=new Map;function l(e){try{const t=new URL(e),n=(t.pathname||"/").replace(/\/+$/,"")||"/";return`${t.protocol}//${t.host}${n}`.toLowerCase()}catch{return String(e||"").toLowerCase()}}function i(e){const t=Date.now();for(const[n,o]of e.entries())o<=t&&e.delete(n)}function R(e){const t=Date.now()+y;w.set(v(e),t),g.set(l(e),t)}function q(e){!Number.isInteger(e)||(e??-1)<0||h.set(e,Date.now()+y)}function N(e){i(w),i(g);const t=v(e);return w.has(t)||g.has(l(e))}function _(e){return i(h),!Number.isInteger(e)||(e??-1)<0?!1:h.has(e)}function E(e){return i(m),m.has(l(e))}function F(e){m.set(l(e),Date.now()+A)}function O(e){return i(a),!!e&&a.has(e)}function P(e){e&&a.set(e,Date.now()+y)}async function $(){try{await I()}catch{}}async function S(e,t=""){if(E(e))return{ok:!1,error:"duplicate transfer suppressed"};const n=await d();if(!n.extensionStatus)return{ok:!1,error:"extension disabled"};if(!n.motrixAPIkey)return{ok:!1,error:"motrixAPIkey is not set"};try{const o=await L({url:e,rpcPort:n.motrixPort,rpcSecret:n.motrixAPIkey,referer:t,split:64});if(!o?.ok)return{ok:!1,error:o?.error||"native host addUri failed"};n.activateAppOnDownload&&await $(),F(e);const s=String(o?.gid||o?.requestId||`pending-${Date.now()}`),U=(()=>{try{return new URL(e).pathname}catch{return""}})().split("/").filter(Boolean).pop()||e;return await T({gid:s,downloader:"native",startTime:new Date().toISOString(),icon:"/images/32.png",name:decodeURIComponent(U),path:null,status:o?.pending?"queued":"downloading",size:0,downloaded:0}),n.enableNotifications&&await r.notifications.create(`gomdown-transfer-${Date.now()}`,{type:"basic",iconUrl:"/images/icon-large.png",title:"Gomdown Helper",message:"Download sent to gdown"}),{ok:!0}}catch(o){return{ok:!1,error:String(o)}}}async function z(e){if(e.type!=="main_frame"||(e.method||"").toUpperCase()!=="GET"||typeof e.statusCode=="number"&&(e.statusCode<200||e.statusCode>299))return!1;const t=await d();if(!t.extensionStatus||!t.motrixAPIkey)return!1;const n=String(Array.isArray(e?.responseHeaders)&&e.responseHeaders.find(s=>String(s?.name||"").toLowerCase()==="content-length")?.value||""),o=Number(n||0);return t.minFileSize>0&&o>0&&o<t.minFileSize*1024*1024?!1:k(e)}async function G(e){if(O(e.requestId)||!await z(e))return;const n=c.get(e.requestId),o=String(n?.documentUrl||n?.originUrl||n?.initiator||n?.url||"");(await S(e.url,o)).ok&&(P(e.requestId),R(e.url),q(e.tabId))}async function u(){const e=r.downloads;if(!e.setShelfEnabled)return;const t=await d();if(!t.extensionStatus)return;const n=t.useNativeHost?!1:!t.hideChromeBar;await e.setShelfEnabled(n)}function b(){r.downloads.onCreated.addListener(async e=>{await u();const t=e,n=t.finalUrl||t.url||"";!N(n)&&!_(t.tabId)||(await r.downloads.cancel(e.id).catch(()=>null),await r.downloads.erase({id:e.id}).catch(()=>null),await r.downloads.removeFile(e.id).catch(()=>null))})}function x(){r.webRequest.onSendHeaders.addListener(e=>{c.set(e.requestId,e)},{urls:["<all_urls>"]},["requestHeaders","extraHeaders"]),r.webRequest.onErrorOccurred.addListener(e=>{c.delete(e.requestId),a.delete(String(e.requestId))},{urls:["<all_urls>"]}),r.webRequest.onCompleted.addListener(e=>{c.delete(e.requestId),a.delete(String(e.requestId))},{urls:["<all_urls>"]}),r.webRequest.onHeadersReceived.addListener(e=>{G(e)},{urls:["<all_urls>"]},["responseHeaders"])}function f(){r.contextMenus.removeAll().then(async()=>{const e=await d();e.showContextOption&&r.contextMenus.create({id:D,title:"Download with Gomdown",visible:e.showContextOption,contexts:["all"]})}),r.contextMenus.onClicked.addListener(async e=>{const t=e.linkUrl||e.srcUrl||e.pageUrl;t&&await S(t)})}r.runtime.onMessage.addListener((e,t)=>{if(e?.type!=="capture-link-download")return;const n=String(e?.url||"").trim();if(!n)return Promise.resolve({ok:!1,error:"url is empty"});const o=Number(t?.tab?.id);return S(n,String(e?.referer||"")).then(s=>(s.ok&&(R(n),q(o)),s))});r.runtime.onInstalled.addListener(()=>{x(),b(),f(),u()});r.runtime.onStartup.addListener(()=>{x(),b(),f(),u()});r.storage.onChanged.addListener((e,t)=>{t==="sync"&&((e.hideChromeBar||e.useNativeHost||e.extensionStatus)&&u(),e.showContextOption&&f())});x();b();f();u();

View File

@@ -0,0 +1,13 @@
(function () {
'use strict';
const injectTime = performance.now();
(async () => {
const { onExecute } = await import(
/* @vite-ignore */
chrome.runtime.getURL("assets/index.ts-BGLNJwsP.js")
);
onExecute?.({ perf: { injectTime, loadTime: performance.now() - injectTime } });
})().catch(console.error);
})();

View File

@@ -0,0 +1 @@
import{b as e}from"./browser-polyfill-CZ_dLIqp.js";const t={extensionStatus:!0,useNativeHost:!0,activateAppOnDownload:!0,enableNotifications:!0,hideChromeBar:!0,showContextOption:!0,downloadFallback:!1,darkMode:!1,showOnlyAria:!1,minFileSize:0,blacklist:[],motrixPort:16800,motrixAPIkey:""};async function n(){const o=await e.storage.sync.get(Object.keys(t));return{extensionStatus:!!(o.extensionStatus??t.extensionStatus),useNativeHost:!!(o.useNativeHost??t.useNativeHost),activateAppOnDownload:!!(o.activateAppOnDownload??t.activateAppOnDownload),enableNotifications:!!(o.enableNotifications??t.enableNotifications),hideChromeBar:!!(o.hideChromeBar??t.hideChromeBar),showContextOption:!!(o.showContextOption??t.showContextOption),downloadFallback:!!(o.downloadFallback??t.downloadFallback),darkMode:!!(o.darkMode??t.darkMode),showOnlyAria:!!(o.showOnlyAria??t.showOnlyAria),minFileSize:Number(o.minFileSize??t.minFileSize),blacklist:Array.isArray(o.blacklist)?o.blacklist.map(a=>String(a)):t.blacklist,motrixPort:Number(o.motrixPort??t.motrixPort),motrixAPIkey:String(o.motrixAPIkey??t.motrixAPIkey)}}async function s(o){await e.storage.sync.set(o)}export{n as g,s};

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,72 @@
{
"manifest_version": 3,
"name": "Gomdown Helper",
"description": "Send browser downloads to gdown",
"version": "0.0.1",
"default_locale": "en",
"icons": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
},
"background": {
"service_worker": "service-worker-loader.js"
},
"action": {
"default_popup": "src/popup/index.html",
"default_title": "Gomdown Helper",
"default_icon": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
}
},
"options_page": "src/config/index.html",
"content_scripts": [
{
"js": [
"assets/index.ts-loader-DMyyuf2n.js"
],
"matches": [
"<all_urls>"
],
"run_at": "document_start",
"all_frames": true
}
],
"permissions": [
"downloads",
"downloads.shelf",
"notifications",
"storage",
"contextMenus",
"cookies",
"webRequest",
"nativeMessaging"
],
"host_permissions": [
"<all_urls>"
],
"web_accessible_resources": [
{
"matches": [
"<all_urls>"
],
"resources": [
"images/*",
"assets/browser-polyfill-CZ_dLIqp.js",
"assets/downloadIntent-Dv31jC2S.js",
"assets/index.ts-BGLNJwsP.js"
],
"use_dynamic_url": false
}
],
"short_name": "Gomdown",
"browser_specific_settings": {
"gecko": {
"id": "gomdown-helper@projectdx"
}
}
}

View File

@@ -0,0 +1 @@
import './assets/index.ts-BnPsJZXz.js';

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper Settings</title>
<script type="module" crossorigin src="/assets/index.html-B0Kfv8fq.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-B2D5FcJM.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gomdown Helper</title>
<script type="module" crossorigin src="/assets/index.html-D-JbSuV5.js"></script>
<link rel="modulepreload" crossorigin href="/assets/browser-polyfill-CZ_dLIqp.js">
<link rel="modulepreload" crossorigin href="/assets/client-CBvt1tWS.js">
<link rel="modulepreload" crossorigin href="/assets/settings-Bo6W9Drl.js">
<link rel="stylesheet" crossorigin href="/assets/index-BZvbrf4l.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.