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

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};