// ==UserScript== // @name X(Twitter) Downloader // @name:zh-CN X(Twitter)下载器 // @author mengshouer // @version 1.0.8 // @description For X(Twitter) add download buttons for images and videos. Settings available by hovering mouse to the bottom left corner or via Tampermonkey menu. // @description:zh-CN 为 X(Twitter) 的图片和视频添加下载按钮。鼠标移入浏览器左下角或油猴菜单可打开设置。 // @include *://twitter.com/* // @include *://*.twitter.com/* // @include *://x.com/* // @include *://*.x.com/* // @license GPL-3.0 License // @namespace https://github.com/mengshouer/UserScripts // @grant GM_registerMenuCommand // ==/UserScript== (function(){"use strict";var se,y,Ke,V,Ye,Je,Ze,Qe,Te,Ee,Ae,K={},Xe=[],fo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ae=Array.isArray;function $(t,e){for(var o in e)t[o]=e[o];return t}function Ce(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ie(t,e,o){var n,r,i,s={};for(i in e)i=="key"?n=e[i]:i=="ref"?r=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?se.call(arguments,2):o),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return le(t,s,n,r,null)}function le(t,e,o,n,r){var i={type:t,props:e,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Ke,__i:-1,__u:0};return r==null&&y.vnode!=null&&y.vnode(i),i}function Y(t){return t.children}function ce(t,e){this.props=t,this.context=e}function F(t,e){if(e==null)return t.__?F(t.__,t.__i+1):null;for(var o;ea&&V.sort(Ze),t=V.shift(),a=V.length,t.__d&&(o=void 0,n=void 0,r=(n=(e=t).__v).__e,i=[],s=[],e.__P&&((o=$({},n)).__v=n.__v+1,y.vnode&&y.vnode(o),Le(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??F(n),!!(32&n.__u),s),o.__v=n.__v,o.__.__k[o.__i]=o,st(i,o,s),n.__e=n.__=null,o.__e!=r&&et(o)));de.__r=0}function ot(t,e,o,n,r,i,s,a,d,c,f){var l,_,p,h,b,x,w,g=n&&n.__k||Xe,C=e.length;for(d=_o(o,e,g,d,C),l=0;l0?s=t.__k[i]=le(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[i]=s,d=i+_,s.__=t,s.__b=t.__b+1,a=null,(c=s.__i=po(s,o,d,l))!=-1&&(l--,(a=o[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(r>f?_--:rd?_--:_++,s.__u|=4))):t.__k[i]=null;if(l)for(i=0;i(f?1:0)){for(r=o-1,i=o+1;r>=0||i=0?r--:i++])!=null&&(2&c.__u)==0&&a==c.key&&d==c.type)return s}return-1}function it(t,e,o){e[0]=="-"?t.setProperty(e,o??""):t[e]=o==null?"":typeof o!="number"||fo.test(e)?o:o+"px"}function ue(t,e,o,n,r){var i,s;e:if(e=="style")if(typeof o=="string")t.style.cssText=o;else{if(typeof n=="string"&&(t.style.cssText=n=""),n)for(e in n)o&&e in o||it(t.style,e,"");if(o)for(e in o)n&&o[e]==n[e]||it(t.style,e,o[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(Qe,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=o,o?n?o.u=n.u:(o.u=Te,t.addEventListener(e,i?Ae:Ee,i)):t.removeEventListener(e,i?Ae:Ee,i);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&o==1?"":o))}}function rt(t){return function(e){if(this.l){var o=this.l[e.type+t];if(e.t==null)e.t=Te++;else if(e.t0?t:ae(t)?t.map(at):$({},t)}function ho(t,e,o,n,r,i,s,a,d){var c,f,l,_,p,h,b,x=o.props||K,w=e.props,g=e.type;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c=o.__.length&&o.__.push({}),o.__[t]}function I(t){return fe=1,vo(wt,t)}function vo(t,e,o){var n=Pe(Z++,2);if(n.t=t,!n.__c&&(n.__=[wt(void 0,e),function(a){var d=n.__N?n.__N[0]:n.__[0],c=n.t(d,a);d!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=S,!S.__f)){var r=function(a,d,c){if(!n.__c.__H)return!0;var f=n.__c.__H.__.filter(function(_){return!!_.__c});if(f.every(function(_){return!_.__N}))return!i||i.call(this,a,d,c);var l=n.__c.props!==a;return f.forEach(function(_){if(_.__N){var p=_.__[0];_.__=_.__N,_.__N=void 0,p!==_.__[0]&&(l=!0)}}),i&&i.call(this,a,d,c)||l};S.__f=!0;var i=S.shouldComponentUpdate,s=S.componentWillUpdate;S.componentWillUpdate=function(a,d,c){if(this.__e){var f=i;i=void 0,r(a,d,c),i=f}s&&s.call(this,a,d,c)},S.shouldComponentUpdate=r}return n.__N||n.__}function B(t,e){var o=Pe(Z++,3);!k.__s&&vt(o.__H,e)&&(o.__=t,o.u=e,S.__H.__h.push(o))}function Be(t){return fe=5,wo(function(){return{current:t}},[])}function wo(t,e){var o=Pe(Z++,7);return vt(o.__H,e)&&(o.__=t(),o.__H=e,o.__h=t),o.__}function yo(){for(var t;t=dt.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(_e),t.__H.__h.forEach(He),t.__H.__h=[]}catch(e){t.__H.__h=[],k.__e(e,t.__v)}}k.__b=function(t){S=null,ut&&ut(t)},k.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),mt&&mt(t,e)},k.__r=function(t){ft&&ft(t),Z=0;var e=(S=t.__c).__H;e&&($e===S?(e.__h=[],S.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(e.__h.forEach(_e),e.__h.forEach(He),e.__h=[],Z=0)),$e=S},k.diffed=function(t){_t&&_t(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(dt.push(e)!==1&&ct===k.requestAnimationFrame||((ct=k.requestAnimationFrame)||bo)(yo)),e.__H.__.forEach(function(o){o.u&&(o.__H=o.u),o.u=void 0})),$e=S=null},k.__c=function(t,e){e.some(function(o){try{o.__h.forEach(_e),o.__h=o.__h.filter(function(n){return!n.__||He(n)})}catch(n){e.some(function(r){r.__h&&(r.__h=[])}),e=[],k.__e(n,o.__v)}}),pt&&pt(t,e)},k.unmount=function(t){ht&&ht(t);var e,o=t.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{_e(n)}catch(r){e=r}}),o.__H=void 0,e&&k.__e(e,o.__v))};var gt=typeof requestAnimationFrame=="function";function bo(t){var e,o=function(){clearTimeout(n),gt&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(o,35);gt&&(e=requestAnimationFrame(o))}function _e(t){var e=S,o=t.__c;typeof o=="function"&&(t.__c=void 0,o()),S=e}function He(t){var e=S;t.__c=t.__(),S=e}function vt(t,e){return!t||t.length!==e.length||e.some(function(o,n){return o!==t[n]})}function wt(t,e){return typeof e=="function"?e(t):e}const pe="m-userscript-settings",Ve="m-open-settings-panel",ze=`${pe}-changed`;class xo{constructor(e,o){this.storageKey=e,this.defaultSettings=o}loadSettings(){try{const e=localStorage.getItem(this.storageKey);if(e){const o=JSON.parse(e);return{...this.defaultSettings,...o}}}catch{}return{...this.defaultSettings}}saveSettings(e){const n={...this.loadSettings(),...e};try{localStorage.setItem(this.storageKey,JSON.stringify(n))}catch{}return n}resetSettings(){try{localStorage.removeItem(this.storageKey)}catch{}return{...this.defaultSettings}}}function So(t){t.stopPropagation(),t.preventDefault()}let Q=0;const yt=t=>{t.preventDefault(),t.returnValue=""},bt={add:()=>{Q===0&&window.addEventListener("beforeunload",yt),Q++},remove:()=>{Q--,Q<=0&&(Q=0,window.removeEventListener("beforeunload",yt))}};async function xt(t,e){bt.add();try{const o=await fetch(t);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const n=await o.blob(),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}catch(o){throw o}finally{bt.remove()}}function ko(t){const e=t.split("?")[0]?.split("/").pop()||"",o=t.includes("format=png")?"png":"jpg";return{picname:e,ext:o}}function St(t,e){let o=t;for(const[n,r]of Object.entries(e))o=o.replace(new RegExp(`<%${n}>`,"g"),r||"");return o}function he(t){const e=/https:\/\/(twitter|x)\.com\//,o=t.replace(e,"").split("/");return{userid:o[0]||"unknown",tid:o[2]||"unknown",picno:o[4]||"1"}}let To={data:""},Eo=t=>{if(typeof window=="object"){let e=(t?t.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||To},Ao=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Co=/\/\*[^]*?\*\/| +/g,kt=/\n+/g,H=(t,e)=>{let o="",n="",r="";for(let i in t){let s=t[i];i[0]=="@"?i[1]=="i"?o=i+" "+s+";":n+=i[1]=="f"?H(s,i):i+"{"+H(s,i[1]=="k"?"":e)+"}":typeof s=="object"?n+=H(s,e?e.replace(/([^,])+/g,a=>i.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,d=>/&/.test(d)?d.replace(/&/g,a):a?a+" "+d:d)):i):s!=null&&(i=/^--/.test(i)?i:i.replace(/[A-Z]/g,"-$&").toLowerCase(),r+=H.p?H.p(i,s):i+":"+s+";")}return o+(e&&r?e+"{"+r+"}":r)+n},P={},Tt=t=>{if(typeof t=="object"){let e="";for(let o in t)e+=o+Tt(t[o]);return e}return t},Io=(t,e,o,n,r)=>{let i=Tt(t),s=P[i]||(P[i]=(d=>{let c=0,f=11;for(;c>>0;return"go"+f})(i));if(!P[s]){let d=i!==t?t:(c=>{let f,l,_=[{}];for(;f=Ao.exec(c.replace(Co,""));)f[4]?_.shift():f[3]?(l=f[3].replace(kt," ").trim(),_.unshift(_[0][l]=_[0][l]||{})):_[0][f[1]]=f[2].replace(kt," ").trim();return _[0]})(t);P[s]=H(r?{["@keyframes "+s]:d}:d,o?"":"."+s)}let a=o&&P.g?P.g:null;return o&&(P.g=P[s]),((d,c,f,l)=>{l?c.data=c.data.replace(l,d):c.data.indexOf(d)===-1&&(c.data=f?d+c.data:c.data+d)})(P[s],e,n,a),s},Lo=(t,e,o)=>t.reduce((n,r,i)=>{let s=e[i];if(s&&s.call){let a=s(o),d=a&&a.props&&a.props.className||/^go/.test(a)&&a;s=d?"."+d:a&&typeof a=="object"?a.props?"":H(a,""):a===!1?"":a}return n+r+(s??"")},"");function Re(t){let e=this||{},o=t.call?t(e.p):t;return Io(o.unshift?o.raw?Lo(o,[].slice.call(arguments,1),e.p):o.reduce((n,r)=>Object.assign(n,r&&r.call?r(e.p):r),{}):o,Eo(e.target),e.g,e.o,e.k)}let Et,Fe,Ue;Re.bind({g:1});let Do=Re.bind({k:1});function No(t,e,o,n){H.p=e,Et=t,Fe=o,Ue=n}function T(t,e){let o=this||{};return function(){let n=arguments;function r(i,s){let a=Object.assign({},i),d=a.className||r.className;o.p=Object.assign({theme:Fe&&Fe()},a),o.o=/ *go\d+/.test(d),a.className=Re.apply(o,n)+(d?" "+d:"");let c=t;return t[0]&&(c=a.as||t,delete a.as),Ue&&c[0]&&Ue(a),Et(c,a)}return r}}No(Ie);const $o=T("div")` position: relative; min-width: 250px; max-width: 400px; padding: 12px 16px; border-radius: 6px; font-size: 14px; line-height: 1.4; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); cursor: pointer; color: #fff; &.message-success { --msg-color: 34, 197, 94; } &.message-error { --msg-color: 239, 68, 68; } &.message-warning { --msg-color: 245, 158, 11; } &.message-info { --msg-color: 59, 130, 246; } &[class*="message-"] { background-color: rgba(var(--msg-color), 0.4); border: 1px solid rgba(var(--msg-color), 0.7); } `,Po=T("span")` float: right; margin-left: 8px; font-weight: bold; opacity: 0.7; font-size: 16px; line-height: 1; &:hover { opacity: 1; } `;function Bo({type:t="info",content:e,duration:o=3e3,onClose:n,onClick:r,className:i,style:s}){const a=Be(null),d=Be(0),c=Be(o),f=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=h=>{f(),h>0&&(d.current=Date.now(),a.current=window.setTimeout(()=>{n?.()},h))},_=()=>{if(a.current){const h=Date.now()-d.current;c.current=Math.max(0,c.current-h),f()}},p=()=>{c.current>0&&l(c.current)};return B(()=>(o>0&&(c.current=o,l(o)),f),[o,n]),u($o,{className:`message-${t} ${i||""}`,style:s,onClick:()=>{r?.(),n?.()},onMouseEnter:_,onMouseLeave:p,children:[e,u(Po,{children:"×"})]})}const Ho=()=>{try{return JSON.parse(localStorage.getItem(pe)||"{}").messagePlacement||"top"}catch{return"top"}},X=new Map;let Vo=0;const zo=t=>{const[e,o]=t.split("-");let i=`${e}: 20px; display: flex; flex-direction: ${e==="bottom"?"column-reverse":"column"};`;return o?i+=` ${o}: 20px;`:i+=" left: 50%; transform: translateX(-50%);",i},Ro=(t="top")=>{if(!X.has(t)){const e=document.createElement("div");e.id=`userscript-message-container-${t}`,e.style.cssText=` position: fixed; z-index: 9999; pointer-events: none; ${zo(t)} `,document.body.appendChild(e),X.set(t,e)}return X.get(t)},Fo=t=>{const e=t.placement||"top",o=Ro(e),n=`userscript-message-${++Vo}`,r=document.createElement("div");r.id=n;const i=e.startsWith("bottom");r.style.cssText=` position: relative; margin-bottom: 8px; pointer-events: auto; animation: ${i?"messageSlideInBottom":"messageSlideIn"} 0.3s ease-out; `,o.appendChild(r);const s=()=>{if(r.parentNode){const a=e.startsWith("bottom");r.style.animation=`${a?"messageSlideOutBottom":"messageSlideOut"} 0.3s ease-in forwards`,setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r)},300)}};return J(Ie(Bo,{...t,onClose:s}),r),s},me=t=>(e,o,n,r)=>Fo({type:t,content:e,placement:n||Ho(),...r&&{onClick:r},...o!==void 0&&{duration:o}}),Uo=me("success"),Mo=me("error"),Oo=me("warning"),Wo=me("info"),E={success:Uo,error:Mo,warning:Oo,info:Wo,destroy:()=>{X.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),X.clear()}},At="userscript-message-styles";if(!document.getElementById(At)){const t=document.createElement("style");t.id=At,t.textContent=` @keyframes messageSlideIn { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes messageSlideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-100%); opacity: 0; } } @keyframes messageSlideInBottom { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes messageSlideOutBottom { from { transform: translateY(0); opacity: 1; } to { transform: translateY(100%); opacity: 0; } } `,document.head.appendChild(t)}const Ct="en",It="userscript-locale";let U=Ct;const ge={},ve=[],Lt=()=>navigator?.language?.toLowerCase().startsWith("zh")?"zh":"en";try{U=localStorage.getItem(It)||Lt()}catch{U=Lt()}const Dt=(t,e)=>{const o={...t};for(const n of Object.keys(e))e[n]!==null&&typeof e[n]=="object"&&!Array.isArray(e[n])&&t[n]!==null&&typeof t[n]=="object"&&!Array.isArray(t[n])?o[n]=Dt(t[n],e[n]):o[n]=e[n];return o},Nt=(t,e)=>{let o=t;for(const n of e.split("."))if(o=o?.[n],!o)return;return typeof o=="string"?o:void 0},jo=(t,e)=>e?t.replace(/\{(\w+)\}/g,(o,n)=>e[n]??"{"+n+"}"):t;function qo(t,e){const o=typeof t=="string"?t:t.key,n=typeof t=="string"?e:t.params,r=Nt(ge[U],o)||Nt(ge[Ct],o)||o;return jo(r,n)}const m={addTranslations(t,e){ge[t]=Dt(ge[t]||{},e)},setLocale(t){if(U!==t){U=t;try{localStorage.setItem(It,t)}catch{}ve.forEach(e=>e())}},getLocale(){return U},t:qo,subscribe(t){return ve.push(t),()=>{const e=ve.indexOf(t);e>-1&&ve.splice(e,1)}}};function we(){const[t,e]=I(m.getLocale());B(()=>m.subscribe(()=>{e(m.getLocale())}),[]);const o=n=>m.setLocale(n);return{t:m.t,locale:t,setLocale:o}}async function $t(t){try{let e=!1;if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t),e=!0;else{const o=document.createElement("textarea");o.value=t,o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.focus(),o.select(),e=document.execCommand("copy"),document.body.removeChild(o)}return e?E.success(m.t("ui.copied")):E.error(m.t("ui.copyFailed")),e}catch{return E.error(m.t("ui.copyFailed")),!1}}function Go(t){return{textColor:t?"#e1e8ed":"#333",backgroundColor:t?"#1e1e1e":"white",borderColor:t?"#38444d":"#ddd",secondaryTextColor:t?"#8b98a5":"#666",inputBackground:t?"#253341":"white",inputBorder:t?"#38444d":"#ddd",panelBackground:t?"#1e1e1e":"white"}}function L(){const[t,e]=I(()=>window.matchMedia?.("(prefers-color-scheme: dark)").matches||!1);return B(()=>{const o=window.matchMedia("(prefers-color-scheme: dark)"),n=r=>e(r.matches);if(o.addEventListener)return o.addEventListener("change",n),()=>o.removeEventListener("change",n);if(o.addListener)return o.addListener(n),()=>o.removeListener?.(n)},[]),{theme:Go(t),isDark:t}}var Ko=Symbol.for("preact-signals");function Me(){if(M>1)M--;else{for(var t,e=!1;ee!==void 0;){var o=ee;for(ee=void 0,Oe++;o!==void 0;){var n=o.o;if(o.o=void 0,o.f&=-3,!(8&o.f)&&Vt(o))try{o.c()}catch(r){e||(t=r,e=!0)}o=n}}if(Oe=0,M--,e)throw t}}var v=void 0;function Pt(t){var e=v;v=void 0;try{return t()}finally{v=e}}var ee=void 0,M=0,Oe=0,ye=0;function Bt(t){if(v!==void 0){var e=t.n;if(e===void 0||e.t!==v)return e={i:0,S:t,p:v.s,n:void 0,t:v,e:void 0,x:void 0,r:e},v.s!==void 0&&(v.s.n=e),v.s=e,t.n=e,32&v.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=v.s,e.n=void 0,v.s.n=e,v.s=e),e}}function A(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}A.prototype.brand=Ko,A.prototype.h=function(){return!0},A.prototype.S=function(t){var e=this,o=this.t;o!==t&&t.e===void 0&&(t.x=o,this.t=t,o!==void 0?o.e=t:Pt(function(){var n;(n=e.W)==null||n.call(e)}))},A.prototype.U=function(t){var e=this;if(this.t!==void 0){var o=t.e,n=t.x;o!==void 0&&(o.x=n,t.e=void 0),n!==void 0&&(n.e=o,t.x=void 0),t===this.t&&(this.t=n,n===void 0&&Pt(function(){var r;(r=e.Z)==null||r.call(e)}))}},A.prototype.subscribe=function(t){var e=this;return Zo(function(){var o=e.value,n=v;v=void 0;try{t(o)}finally{v=n}},{name:"sub"})},A.prototype.valueOf=function(){return this.value},A.prototype.toString=function(){return this.value+""},A.prototype.toJSON=function(){return this.value},A.prototype.peek=function(){var t=v;v=void 0;try{return this.value}finally{v=t}},Object.defineProperty(A.prototype,"value",{get:function(){var t=Bt(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Oe>100)throw new Error("Cycle detected");this.v=t,this.i++,ye++,M++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Me()}}}});function Ht(t,e){return new A(t,e)}function Vt(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function zt(t){for(var e=t.s;e!==void 0;e=e.n){var o=e.S.n;if(o!==void 0&&(e.r=o),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Rt(t){for(var e=t.s,o=void 0;e!==void 0;){var n=e.p;e.i===-1?(e.S.U(e),n!==void 0&&(n.n=e.n),e.n!==void 0&&(e.n.p=n)):o=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=n}t.s=o}function z(t,e){A.call(this,void 0),this.x=t,this.s=void 0,this.g=ye-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}z.prototype=new A,z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ye))return!0;if(this.g=ye,this.f|=1,this.i>0&&!Vt(this))return this.f&=-2,!0;var t=v;try{zt(this),v=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(o){this.v=o,this.f|=16,this.i++}return v=t,Rt(this),this.f&=-2,!0},z.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}A.prototype.S.call(this,t)},z.prototype.U=function(t){if(this.t!==void 0&&(A.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}},z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}},Object.defineProperty(z.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Bt(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Yo(t,e){return new z(t,e)}function Ft(t){var e=t.u;if(t.u=void 0,typeof e=="function"){M++;var o=v;v=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,We(t),n}finally{v=o,Me()}}}function We(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Ft(t)}function Jo(t){if(v!==this)throw new Error("Out-of-order effect");Rt(this),v=t,this.f&=-2,8&this.f&&We(this),Me()}function O(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name}O.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}},O.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ft(this),zt(this),M++;var t=v;return v=this,Jo.bind(this,t)},O.prototype.N=function(){2&this.f||(this.f|=2,this.o=ee,ee=this)},O.prototype.d=function(){this.f|=8,1&this.f||We(this)},O.prototype.dispose=function(){this.d()};function Zo(t,e){var o=new O(t,e);try{o.c()}catch(r){throw o.d(),r}var n=o.d.bind(o);return n[Symbol.dispose]=n,n}const W=new Map;let Ut=!1;function Qo(t){if(!W.has(t)){const e=Ht(!1);return W.set(t,e),e}return W.get(t)}const Xo=t=>{const e=W.get(t.key);e&&!e.value&&(e.value=!0)},en=t=>{const e=W.get(t.key);e&&e.value&&(e.value=!1)},tn=()=>{W.forEach(t=>{t.value&&(t.value=!1)})};function on(){Ut||(window.addEventListener("keydown",Xo),window.addEventListener("keyup",en),window.addEventListener("blur",tn),Ut=!0)}function nn(t){const e=Qo(t),[o,n]=I(e.value);return B(()=>{on();const r=e.subscribe(i=>{n(i)});return n(e.value),()=>{r()}},[t,e]),o??!1}const rn=T("button")` /* Base styles */ border-radius: 6px; font-weight: 500; outline: none; border: none; cursor: var(--cursor); opacity: var(--opacity); /* Size variants */ padding: var(--padding); font-size: var(--font-size); /* Color variants */ background: var(--bg); color: var(--color); border: var(--border); `,sn={primary:{"--bg":"#1da1f2","--color":"white","--border":"none"},secondary:t=>({"--bg":t.inputBackground,"--color":t.textColor,"--border":`1px solid ${t.borderColor}`}),danger:{"--bg":"#dc3545","--color":"white","--border":"none"}},an={small:{"--padding":"6px 12px","--font-size":"12px"},medium:{"--padding":"8px 16px","--font-size":"14px"},large:{"--padding":"12px 24px","--font-size":"16px"}};function te({children:t,onClick:e,disabled:o=!1,variant:n="primary",size:r="medium",className:i="",style:s={},type:a="button"}){const{theme:d}=L(),f={...(()=>{const l=sn[n];return typeof l=="function"?l(d):l})(),...an[r],"--cursor":o?"not-allowed":"pointer","--opacity":o?"0.6":"1",...s};return u(rn,{className:i,style:f,onClick:e,disabled:o,type:a,children:t})}const ln=T("label")` display: flex; align-items: center; cursor: var(--cursor); color: var(--text-color); opacity: var(--opacity); `,cn=T("input")` margin-right: 8px; accent-color: #1da1f2; cursor: var(--cursor); `;function oe({checked:t,defaultChecked:e,disabled:o=!1,onChange:n,children:r,className:i="",style:s={}}){const{theme:a}=L(),d={"--cursor":o?"not-allowed":"pointer","--text-color":a.textColor,"--opacity":o?"0.6":"1",...s};return u(ln,{className:i,style:d,children:[u(cn,{type:"checkbox",checked:t,defaultChecked:e,disabled:o,onChange:c=>n?.(c.currentTarget.checked),style:{"--cursor":o?"not-allowed":"pointer"}}),r]})}const dn=T("input")` width: 100%; padding: 8px 12px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--input-text); border-radius: 6px; font-size: 14px; box-sizing: border-box; outline: none; transition: border-color 0.2s ease; &:focus { border-color: #1da1f2; } `;function be({type:t="text",value:e,defaultValue:o,placeholder:n,disabled:r=!1,onChange:i,onBlur:s,onFocus:a,className:d="",style:c={}}){const{theme:f}=L(),l={"--input-border":f.inputBorder,"--input-bg":f.inputBackground,"--input-text":f.textColor,...c};return u(dn,{type:t,value:e,defaultValue:o,placeholder:n,disabled:r,className:d,style:l,onChange:_=>i?.(_.currentTarget.value),onBlur:s,onFocus:a})}function Mt({value:t,options:e,onChange:o,placeholder:n,className:r,style:i}){const{theme:s}=L(),a={padding:"6px 8px",borderRadius:"4px",border:`1px solid ${s.borderColor}`,backgroundColor:s.backgroundColor,color:s.textColor,fontSize:"14px",cursor:"pointer",outline:"none",...i};return u("select",{value:t,onChange:c=>{const f=c.target;o(f.value)},className:r,style:a,children:[n&&u("option",{value:"",disabled:!0,children:n}),e.map(c=>u("option",{value:c.value,children:c.label},c.value))]})}function un({className:t,style:e}){const{theme:o}=L(),{t:n,locale:r,setLocale:i}=we(),s=[{value:"zh",label:"中文"},{value:"en",label:"English"}];return u("div",{className:t,style:{display:"flex",alignItems:"center",gap:"8px",...e},children:[u("label",{style:{fontSize:"14px",fontWeight:500,color:o.textColor,marginBottom:"0"},children:[n("common.language"),":"]}),u(Mt,{value:r,options:s,onChange:a=>i(a)})]})}function fn({value:t,onChange:e,className:o,style:n}){const{theme:r}=L(),{t:i}=we(),s=[{value:"top",label:i("common.messagePlacement.top")},{value:"bottom",label:i("common.messagePlacement.bottom")},{value:"top-left",label:i("common.messagePlacement.topLeft")},{value:"top-right",label:i("common.messagePlacement.topRight")},{value:"bottom-left",label:i("common.messagePlacement.bottomLeft")},{value:"bottom-right",label:i("common.messagePlacement.bottomRight")}],a=d=>{e(d)};return u("div",{className:o,style:{display:"flex",alignItems:"center",gap:"8px",...n},children:[u("label",{style:{fontSize:"14px",fontWeight:500,color:r.textColor,marginBottom:"0"},children:[i("common.messagePlacement.label"),":"]}),u(Mt,{value:t,options:s,onChange:a})]})}const _n=T("div")` position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.5); z-index: 10001; display: flex; align-items: center; justify-content: center; `,pn=T("div")` background: var(--modal-bg); color: var(--modal-text); border-radius: 12px; padding: 24px; min-width: 480px; width: auto; max-width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; @media (max-width: 640px) { min-width: auto; width: 90vw; } `;function hn({isOpen:t,onClose:e,title:o,children:n,className:r="",style:i={}}){const{theme:s}=L();if(B(()=>{if(!t)return;const l=_=>{_.key==="Escape"&&e()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,e]),!t)return null;const a={"--modal-bg":s.panelBackground,"--modal-text":s.textColor,...i},d={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:o?"20px":"0"},c={margin:0,color:s.textColor,fontSize:"20px",fontWeight:600},f={background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:s.secondaryTextColor,padding:0,width:"30px",height:"30px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background-color 0.2s ease"};return u(_n,{onClick:e,children:u(pn,{className:r,style:a,onClick:l=>l.stopPropagation(),children:[u("div",{style:d,children:[o&&u("h2",{style:c,children:o}),u("button",{style:f,onClick:e,onMouseEnter:l=>{const _=l.target;_.style.backgroundColor=s.borderColor},onMouseLeave:l=>{const _=l.target;_.style.backgroundColor="transparent"},children:"×"})]}),u("div",{children:n})]})})}const mn=T("div")` background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 0; margin-bottom: 16px; transition: all 0.2s ease; &:last-child { margin-bottom: 0; } `,gn=T("div")` padding: 16px 20px; border-bottom: 1px solid var(--card-border); background: var(--card-header-bg); border-radius: 12px 12px 0 0; `,vn=T("h3")` margin: 0; font-size: 16px; font-weight: 600; color: var(--card-title-color); display: flex; align-items: center; gap: 8px; `,wn=T("div")` padding: 20px; `;function xe({title:t,children:e,className:o="",style:n={}}){const{theme:r,isDark:i}=L(),s={"--card-bg":r.panelBackground,"--card-border":r.borderColor,"--card-header-bg":i?"rgba(255, 255, 255, 0.02)":"rgba(0, 0, 0, 0.01)","--card-title-color":r.textColor,...n};return u(mn,{className:o,style:s,children:[t&&u(gn,{children:u(vn,{children:t})}),u(wn,{children:e})]})}const yn=T("button")` position: fixed; left: var(--left-position); bottom: 20px; width: 40px; height: 40px; background-color: ${t=>t.$bgColor}; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10000; color: white; transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.2s ease, transform 0.2s ease; opacity: 0.9; border: none; &:hover { opacity: 1; transform: scale(1.05); } `,bn=T("svg")` width: 20px; height: 20px; fill: currentColor; `;function xn({onClick:t,isVisible:e,backgroundColor:o="#1da1f2"}){return u(yn,{style:{"--left-position":e?"10px":"-40px"},onClick:t,$bgColor:o,children:u(bn,{viewBox:"0 0 24 24",children:u("path",{d:"M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.82,11.69,4.82,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"})})})}function Sn({values:t,onChange:e}){const{theme:o}=L(),{t:n}=we(),r={display:"block",marginBottom:"8px",fontWeight:500,fontSize:"14px",color:o.textColor};return u(xe,{title:n("settings.position.title"),children:u("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[u("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap"},children:[u("div",{style:{flex:"1",minWidth:"120px"},children:[u("label",{style:r,children:n("settings.position.vertical")}),u("div",{style:{display:"flex",gap:"8px"},children:[u(te,{variant:t.buttonPositionVertical==="top"?"primary":"secondary",size:"small",onClick:()=>e("buttonPositionVertical","top"),children:n("settings.position.top")}),u(te,{variant:t.buttonPositionVertical==="bottom"?"primary":"secondary",size:"small",onClick:()=>e("buttonPositionVertical","bottom"),children:n("settings.position.bottom")})]})]}),u("div",{style:{flex:"1",minWidth:"120px"},children:[u("label",{style:r,children:n("settings.position.verticalValue")}),u(be,{value:t.buttonPositionVerticalValue,onChange:i=>e("buttonPositionVerticalValue",i),placeholder:"8"})]})]}),u("div",{style:{display:"flex",gap:"24px",flexWrap:"wrap"},children:[u("div",{style:{flex:"1",minWidth:"120px"},children:[u("label",{style:r,children:n("settings.position.horizontal")}),u("div",{style:{display:"flex",gap:"8px"},children:[u(te,{variant:t.buttonPositionHorizontal==="left"?"primary":"secondary",size:"small",onClick:()=>e("buttonPositionHorizontal","left"),children:n("settings.position.left")}),u(te,{variant:t.buttonPositionHorizontal==="right"?"primary":"secondary",size:"small",onClick:()=>e("buttonPositionHorizontal","right"),children:n("settings.position.right")})]})]}),u("div",{style:{flex:"1",minWidth:"120px"},children:[u("label",{style:r,children:n("settings.position.horizontalValue")}),u(be,{value:t.buttonPositionHorizontalValue,onChange:i=>e("buttonPositionHorizontalValue",i),placeholder:"8"})]})]}),u("div",{style:{fontSize:"12px",color:o.secondaryTextColor},children:n("settings.position.valueHelp")})]})})}function kn(t,e){const o=new xo(t,e),n=Ht(o.loadSettings()),r=Yo(()=>n.value),i=c=>{const f=o.saveSettings(c);n.value=f,window.dispatchEvent(new CustomEvent(ze))};return{get settings(){return r.value},updateSettings:i,resetSettings:()=>{const c=o.resetSettings();return n.value=c,window.dispatchEvent(new CustomEvent(ze)),c},getSetting:c=>n.value[c],setSetting:(c,f)=>{i({[c]:f})},signal:n}}const j=kn(pe,{fileName:"<%Userid> <%Tid>_p<%PicNo>",showDownloadButton:!0,videoFileName:"<%Userid> <%Tid>",showVideoDownloadButton:!1,showUniversalDownloadButton:!0,autoLikeOnDownload:!1,messagePlacement:"top",buttonPositionVertical:"bottom",buttonPositionHorizontal:"right",buttonPositionVerticalValue:"64",buttonPositionHorizontalValue:"8",hideEditImageButton:!1});function Se(){const[t,e]=I(j.signal.value);return B(()=>{const o=j.signal.subscribe(n=>{e(n)});return()=>o()},[]),{settings:t,setSetting:j.setSetting,updateSettings:j.updateSettings,resetSettings:j.resetSettings,getSetting:j.getSetting}}const Tn={common:{ok:"确定",cancel:"取消",close:"关闭",reset:"重置",save:"保存",loading:"加载中...",error:"错误",success:"成功",warning:"警告",info:"信息",language:"语言",messagePlacement:{label:"消息弹窗位置",top:"顶部居中",bottom:"底部居中",topLeft:"左上角",topRight:"右上角",bottomLeft:"左下角",bottomRight:"右下角"}},button:{download:"下载",settings:"设置"},settings:{position:{title:"按钮位置设置",vertical:"垂直方向",horizontal:"水平方向",top:"上",bottom:"下",left:"左",right:"右",verticalValue:"垂直距离",horizontalValue:"水平距离",valueHelp:"纯数字默认 px,也可输入带单位的值如 1rem、10%"}}},En={common:{ok:"OK",cancel:"Cancel",close:"Close",reset:"Reset",save:"Save",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",info:"Info",language:"Language",messagePlacement:{label:"Message Placement",top:"Top Center",bottom:"Bottom Center",topLeft:"Top Left",topRight:"Top Right",bottomLeft:"Bottom Left",bottomRight:"Bottom Right"}},button:{download:"Download",settings:"Settings"},settings:{position:{title:"Button Position",vertical:"Vertical",horizontal:"Horizontal",top:"Top",bottom:"Bottom",left:"Left",right:"Right",verticalValue:"Vertical Offset",horizontalValue:"Horizontal Offset",valueHelp:"Pure numbers default to px, also supports values like 1rem, 10%"}}},An={title:"X(Twitter) Downloader 设置",settings:{image:{title:"图片下载设置",fileName:"图片文件名格式",fileNamePlaceholder:"<%Userid> <%Tid>_p<%PicNo>",fileNameHelp:"可用变量:<%Userid>、<%Tid>、<%Time>、<%PicName>、<%PicNo>",showButton:"显示图片下载按钮"},video:{title:"视频下载设置",fileName:"视频文件名格式",fileNamePlaceholder:"<%Userid> <%Tid>_video_<%Time>",fileNameHelp:"可用变量:<%Userid>、<%Tid>、<%Time>",showButton:"显示视频下载按钮"},universal:{title:"通用下载设置",showButton:"显示通用下载按钮",showButtonHelp:"在推文操作栏中显示统一的下载按钮,自动检测媒体类型",autoLike:"下载时自动点赞",autoLikeHelp:"下载图片或视频时自动为推文点赞",hideEditImage:"隐藏图片编辑按钮",hideEditImageHelp:'隐藏推文图片上的 "Edit image" 按钮'},reset:"重置为默认设置"},messages:{downloadStart:"开始下载",downloadSuccess:"下载成功",downloadError:"下载失败",noMediaFound:"未找到媒体文件",settingsReset:"设置已重置",imagesDownloadSuccess:"成功下载 {count} 张图片",videoDownloadSuccess:"视频下载成功",cannotRecognizeTweet:"无法识别推文,请重试",videoLinkNotFound:"未找到视频下载链接",tweetAlreadyLiked:"推文已点赞",likeSuccess:"点赞成功",likeButtonNotFound:"未找到点赞按钮",cannotGetAuthInfo:"无法获取认证信息",networkRequestFailed:"网络请求失败 ({status})",likeFailed:"点赞失败: {error}",likeResponseError:"点赞响应异常",downloadFailed:"下载失败",videoDownloadFailed:"视频下载失败",imageDownloadFailed:"图片下载失败"},ui:{downloading:"下载中...",downloadVideo:"下载视频",downloadImage:"下载原图",downloadImages:"下载 {count} 张图片",downloadVideos:"下载 {count} 个视频",copied:"已复制到剪贴板",copyFailed:"复制失败"}},Cn={title:"X(Twitter) Downloader Settings",settings:{image:{title:"Image Download Settings",fileName:"Image filename format",fileNamePlaceholder:"<%Userid> <%Tid>_p<%PicNo>",fileNameHelp:"Available variables: <%Userid>, <%Tid>, <%Time>, <%PicName>, <%PicNo>",showButton:"Show image download button"},video:{title:"Video Download Settings",fileName:"Video filename format",fileNamePlaceholder:"<%Userid> <%Tid>_video_<%Time>",fileNameHelp:"Available variables: <%Userid>, <%Tid>, <%Time>",showButton:"Show video download button"},universal:{title:"Universal Download Settings",showButton:"Show universal download button",showButtonHelp:"Display unified download button in tweet actions, automatically detects media type",autoLike:"Auto-like on download",autoLikeHelp:"Automatically like the tweet when downloading images or videos",hideEditImage:"Hide edit image button",hideEditImageHelp:'Hide the "Edit image" button on tweet images'},reset:"Reset to default settings"},messages:{downloadStart:"Download started",downloadSuccess:"Download successful",downloadError:"Download failed",noMediaFound:"No media found",settingsReset:"Settings reset",imagesDownloadSuccess:"Successfully downloaded {count} images",videoDownloadSuccess:"Video download successful",cannotRecognizeTweet:"Cannot recognize tweet, please try again",videoLinkNotFound:"Video download link not found",tweetAlreadyLiked:"Tweet already liked",likeSuccess:"Like successful",likeButtonNotFound:"Like button not found",cannotGetAuthInfo:"Cannot get authentication info",networkRequestFailed:"Network request failed ({status})",likeFailed:"Like failed: {error}",likeResponseError:"Like response error",downloadFailed:"Download failed",videoDownloadFailed:"Video download failed",imageDownloadFailed:"Image download failed"},ui:{downloading:"Downloading...",downloadVideo:"Download Video",downloadImage:"Download Image",downloadImages:"Download {count} Images",downloadVideos:"Download {count} Videos",copied:"Copied to clipboard",copyFailed:"Copy failed"}};m.addTranslations("zh",Tn),m.addTranslations("zh",An),m.addTranslations("en",En),m.addTranslations("en",Cn);function In({isOpen:t,onClose:e}){const{settings:o,setSetting:n,resetSettings:r}=Se(),{t:i}=we(),{theme:s,isDark:a}=L(),[d,c]=I(0),f={display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:"16px",padding:"16px",marginBottom:"20px",background:a?"rgba(255, 255, 255, 0.02)":"rgba(0, 0, 0, 0.01)",border:`1px solid ${s.borderColor}`,borderRadius:"8px"},l={marginBottom:"20px"},_={display:"block",marginBottom:"8px",fontWeight:500,fontSize:"14px",color:s.textColor},p={marginTop:"6px",fontSize:"12px",color:s.secondaryTextColor,paddingLeft:"24px"};return u(hn,{isOpen:t,onClose:e,title:i("title"),children:u("div",{children:[u("div",{style:f,children:[u("div",{style:{display:"flex",gap:"12px",alignItems:"center",flexWrap:"wrap",flex:"1",minWidth:"0"},children:[u(un,{}),u(fn,{value:o.messagePlacement,onChange:h=>n("messagePlacement",h)})]}),u(te,{variant:"secondary",style:{flexShrink:0},onClick:()=>{r(),c(h=>h+1)},children:i("settings.reset")})]}),u(xe,{title:i("settings.image.title"),children:[u("div",{style:l,children:[u("label",{style:_,children:i("settings.image.fileName")}),u(be,{value:o.fileName,onChange:h=>n("fileName",h),placeholder:i("settings.image.fileNamePlaceholder")}),u("div",{style:{marginTop:"6px",fontSize:"12px",color:s.secondaryTextColor},children:i("settings.image.fileNameHelp")})]}),u(oe,{checked:o.showDownloadButton,onChange:h=>n("showDownloadButton",h),children:i("settings.image.showButton")})]}),u(xe,{title:i("settings.video.title"),children:[u("div",{style:l,children:[u("label",{style:_,children:i("settings.video.fileName")}),u(be,{value:o.videoFileName,onChange:h=>n("videoFileName",h),placeholder:i("settings.video.fileNamePlaceholder")}),u("div",{style:{marginTop:"6px",fontSize:"12px",color:s.secondaryTextColor},children:i("settings.video.fileNameHelp")})]}),u(oe,{checked:o.showVideoDownloadButton,onChange:h=>n("showVideoDownloadButton",h),children:i("settings.video.showButton")})]}),u(xe,{title:i("settings.universal.title"),children:[u("div",{children:[u(oe,{checked:o.showUniversalDownloadButton,onChange:h=>n("showUniversalDownloadButton",h),children:i("settings.universal.showButton")}),u("div",{style:p,children:i("settings.universal.showButtonHelp")})]}),u("div",{style:{marginTop:"16px"},children:[u(oe,{checked:o.autoLikeOnDownload,onChange:h=>n("autoLikeOnDownload",h),children:i("settings.universal.autoLike")}),u("div",{style:p,children:i("settings.universal.autoLikeHelp")})]}),u("div",{style:{marginTop:"16px"},children:[u(oe,{checked:o.hideEditImageButton,onChange:h=>n("hideEditImageButton",h),children:i("settings.universal.hideEditImage")}),u("div",{style:p,children:i("settings.universal.hideEditImageHelp")})]})]}),u(Sn,{values:{buttonPositionVertical:o.buttonPositionVertical,buttonPositionHorizontal:o.buttonPositionHorizontal,buttonPositionVerticalValue:o.buttonPositionVerticalValue,buttonPositionHorizontalValue:o.buttonPositionHorizontalValue},onChange:(h,b)=>n(h,b)})]},d)})}function Ln(){const[t,e]=I(!1),[o,n]=I(!1);return B(()=>{const i=a=>{const d=a.clientX<100&&a.clientY>window.innerHeight*.6666666666666666;n(d)},s=()=>e(!0);return document.addEventListener("mousemove",i),window.addEventListener(Ve,s),()=>{document.removeEventListener("mousemove",i),window.removeEventListener(Ve,s)}},[]),u(Y,{children:[u(xn,{onClick:()=>e(!t),isVisible:o||t,backgroundColor:"#1da1f2"}),u(In,{isOpen:t,onClose:()=>e(!1)})]})}const Dn=Do` 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } `,Nn=T("button")` position: absolute; z-index: 1000; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(0, 0, 0, 0.8); border: 2px solid rgba(255, 255, 255, 0.9); cursor: pointer; opacity: 0.8; transition: opacity 0.2s ease, transform 0.2s ease; transform: scale(1); top: var(--top); right: var(--right); bottom: var(--bottom); left: var(--left); &:hover:not(:disabled) { opacity: 1; transform: scale(1.05); } `,Ot=T("svg")` width: var(--icon-width, 20px); height: var(--icon-height, 20px); fill: var(--icon-color, white); `,$n=T("svg")` width: var(--icon-width, 18px); height: var(--icon-height, 18px); animation: ${Dn} 1s linear infinite; fill: none; color: var(--icon-color, white); `,Pn=u(Ot,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:u("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"})}),Bn=u($n,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:u("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none",strokeDasharray:"31.416",strokeDashoffset:"15.708"})}),Hn=u(Ot,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:u("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})});function Wt({title:t,isDownloading:e=!1,disabled:o=!1,icon:n=Pn,shiftIcon:r=Hn,loadingIcon:i=Bn,style:s={},className:a="",onClick:d}){const c=o||e,f=nn("Shift"),l=h=>{So(h),!c&&d?.(h,f)},_=h=>{const b={};for(const[x,w]of Object.entries(h)){const g=`--${x.replace(/[A-Z]/g,"-$&").toLowerCase()}`;b[g]=w}return b},p={"--cursor":c?"not-allowed":"pointer","--opacity":e?"0.5":"0.8","--transform":e?"scale(0.95)":"scale(1)","--hover-transform":e?"scale(0.95)":"scale(1.05)",...!s.top&&!s.bottom&&{"--bottom":"8px"},...!s.right&&!s.left&&{"--right":"8px"},..._(s)};return u(Nn,{className:a,style:p,onClick:l,onMouseDown:h=>(h.preventDefault(),!1),title:t,disabled:c,children:e?i:f&&r?r:n})}const Vn="https://x.com/i/api/graphql/_8aYOgEDz35BrBcBal1-_w/TweetDetail",zn="Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA",Rn={rweb_video_screen_enabled:!1,profile_label_improvements_pcf_label_in_post_enabled:!0,rweb_tipjar_consumption_enabled:!0,verified_phone_label_enabled:!1,creator_subscriptions_tweet_preview_api_enabled:!0,responsive_web_graphql_timeline_navigation_enabled:!0,responsive_web_graphql_skip_user_profile_image_extensions_enabled:!1,premium_content_api_read_enabled:!1,communities_web_enable_tweet_community_results_fetch:!0,c9s_tweet_anatomy_moderator_badge_enabled:!0,responsive_web_grok_analyze_button_fetch_trends_enabled:!1,responsive_web_grok_analyze_post_followups_enabled:!0,responsive_web_jetfuel_frame:!1,responsive_web_grok_share_attachment_enabled:!0,articles_preview_enabled:!0,responsive_web_edit_tweet_api_enabled:!0,graphql_is_translatable_rweb_tweet_is_translatable_enabled:!0,view_counts_everywhere_api_enabled:!0,longform_notetweets_consumption_enabled:!0,responsive_web_twitter_article_tweet_consumption_enabled:!0,tweet_awards_web_tipping_enabled:!1,responsive_web_grok_show_grok_translated_post:!1,responsive_web_grok_analysis_button_from_backend:!1,creator_subscriptions_quote_tweet_preview_enabled:!1,freedom_of_speech_not_reach_fetch_enabled:!0,standardized_nudges_misinfo:!0,tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled:!0,longform_notetweets_rich_text_read_enabled:!0,longform_notetweets_inline_media_enabled:!0,responsive_web_grok_image_annotation_enabled:!0,responsive_web_enhance_cards_enabled:!1},Fn={withArticlePlainText:!1,withArticleRichContentState:!0,withDisallowedReplyControls:!1,withGrokAnalyze:!1},Un=encodeURIComponent(JSON.stringify(Rn)),Mn=encodeURIComponent(JSON.stringify(Fn)),On=`features=${Un}&fieldToggles=${Mn}`,Wn='","rankingMode":"Relevance","includePromotedContent":false,"withCommunity":false,"withQuickPromoteEligibilityTweetFields":false,"withBirdwatchNotes":false,"withVoice":false}',jn=[["Authorization",zn],["x-twitter-active-user","yes"],["Content-Type","application/json"]];let q;const qn=t=>{const e=encodeURIComponent(`{"focalTweetId":"${t}${Wn}`);return`${Vn}?${On}&variables=${e}`};function Gn(t){if(!Array.isArray(t)||t.length===0)return;const e=t.find(r=>r.type==="video"||r.type==="animated_gif");if(!e||!e.video_info||!Array.isArray(e.video_info.variants))return;const o=e.video_info.variants.filter(r=>r.content_type==="video/mp4"&&r.url);return o.length===0?void 0:o.reduce((r,i)=>(i.bitrate||0)>=(r.bitrate||0)?i:r).url}function Kn(t,e){try{const n=t.data.threaded_conversation_with_injections_v2.instructions.find(r=>r.type==="TimelineAddEntries");if(!n||!Array.isArray(n.entries))return[];for(const r of n.entries){const{content:i,entryId:s}=r,{entryType:a,itemContent:d}=i;if(s===`tweet-${e}`&&a==="TimelineTimelineItem"&&d?.itemType==="TimelineTweet"&&d.tweet_results?.result?.legacy?.extended_entities?.media)return d.tweet_results.result.legacy.extended_entities.media}return[]}catch{return[]}}function Yn(){if(q)return q;const t=document.querySelector('meta[name="csrf-token"]');if(t){const o=t.getAttribute("content")||void 0;if(o)return q=o,o}const e=document.cookie.split(";");for(const o of e){const[n,r]=o.trim().split("=");if(n==="ct0"&&r)return q=decodeURIComponent(r),q}}async function Jn(t,e){const o=new Headers(jn);o.set("x-csrf-token",e),o.set("User-Agent",navigator.userAgent);const n=await fetch(qn(t),{method:"GET",headers:o,credentials:"include"});if(!n.ok)throw new Error(`Failed to fetch tweet data: ${n.status} ${n.statusText}`);return await n.json()}async function Zn(t){try{const e=Yn();if(!e)throw new Error("Could not find CSRF token");const o=await Jn(t,e),n=Kn(o,t);return Gn(n)}catch(e){throw q=void 0,e}}function Qn(t){let e=t.parentElement;for(;e&&e.tagName!=="BODY";){if(e.hasAttribute("data-testid")&&e.getAttribute("data-testid")==="videoComponent")return e;e=e.parentElement}return null}function Xn(t){let e=t.parentElement;for(;e&&e.tagName!=="BODY";){if(e.hasAttribute("data-testid")&&e.getAttribute("data-testid")==="videoPlayer")return e;e=e.parentElement}return null}function ei(t){const o=`; ${document.cookie}`.split(`; ${t}=`);return o.length===2&&o.pop()?.split(";").shift()||null}const ti='button[data-testid="like"]',je='button[data-testid="unlike"]',oi=5,ni=200,ii="https://x.com/i/api/graphql/lI07N6Otwv1PhnEgXILM7A/FavoriteTweet",ri="Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA";async function jt(t,e){try{if(t){const o=await si(t);if(o==="success"||o==="already-liked")return{success:!0}}return await ci(e)}catch(o){const n=o instanceof Error?o.message:String(o);return{success:!1,message:m.t("messages.likeFailed",{error:n})}}}async function si(t){if(t.querySelector(je))return"already-liked";const o=t.querySelector(ti);if(!o)return"fallback";try{o.click()}catch{return"fallback"}return await ai(t,o)?(E.info(m.t("messages.likeSuccess")),"success"):"fallback"}async function ai(t,e){for(let r=0;rwindow.setTimeout(d,ni))}return t.querySelector(je)||e.getAttribute("data-testid")==="unlike"?!0:e.getAttribute("aria-pressed")==="true"}function li(){const t=ei("ct0"),e=document.cookie;return!t||!e?null:{accept:"*/*","accept-language":"en-US,en;q=0.9",authorization:ri,"content-type":"application/json","x-csrf-token":t,"x-twitter-active-user":"yes","x-twitter-auth-type":"OAuth2Session","x-twitter-client-language":"en",cookie:e}}async function ci(t){const e=li();if(!e)return{success:!1,message:m.t("messages.cannotGetAuthInfo")};const o={variables:{tweet_id:t},queryId:"lI07N6Otwv1PhnEgXILM7A"};try{const n=await fetch(ii,{method:"POST",headers:e,body:JSON.stringify(o)});if(!n.ok)return{success:!1,message:m.t("messages.networkRequestFailed",{status:n.status})};const{errors:r,data:i}=await n.json();if(r&&r.length>0){const[s]=r,{code:a,name:d,message:c}=s||{};if(a===139&&d==="AuthorizationError")return E.info(m.t("messages.tweetAlreadyLiked")),{success:!0};const f=c||"未知错误";return{success:!1,message:m.t("messages.likeFailed",{error:f})}}return i?.favorite_tweet==="Done"?(E.info(m.t("messages.likeSuccess")),{success:!0}):{success:!1,message:m.t("messages.likeResponseError")}}catch(n){const r=n instanceof Error?n.message:String(n);return{success:!1,message:m.t("messages.likeFailed",{error:r})}}}function qt(t){return/^\d+$/.test(t.trim())?`${t.trim()}px`:t}function Gt(t){return{[t.buttonPositionVertical]:qt(t.buttonPositionVerticalValue),[t.buttonPositionHorizontal]:qt(t.buttonPositionHorizontalValue)}}function Kt(t,e=m.t("messages.downloadFailed")){const o=t instanceof Error?t.message:String(t);E.error(`${e}: ${o}`)}function Yt(t){let e=t;for(;e&&e.tagName!=="BODY";){if(e.tagName==="ARTICLE"&&e.getAttribute("data-testid")==="tweet"||e.getAttribute("role")==="dialog")return e;e=e.parentElement}return null}function di(t,e=""){let o=t;for(;o&&o.tagName!=="BODY";){if(o.tagName==="ARTICLE"&&o.hasAttribute("data-testid")&&o.getAttribute("data-testid")==="tweet"){const i=o.querySelectorAll(`a[href*="${e}/status/"]`);for(const s of Array.from(i)){const d=s.href.match(/\/status\/(\d+)/);if(d)return d[1]}}o=o.parentElement}const n=window.location.href.match(/\/status\/(\d+)/);if(n)return n[1]}function ne(t){const e=t.closest('[role="link"]');if(e&&e.querySelector("time"))return!0;const o=t.closest('[id^="id"]:not([aria-labelledby])');return!!(o&&o.querySelector("time"))}function ui(t){const e=t.querySelectorAll('img[src^="https://pbs.twimg.com/media/"]');return Array.from(e).some(o=>!ne(o))}function fi(t){const e=t.querySelectorAll("video");return Array.from(e).some(o=>!ne(o))}function Jt(t){const e=t.querySelectorAll('img[src^="https://pbs.twimg.com/media/"]');return Array.from(e).filter(o=>!ne(o))}function Zt(t){const e=t.querySelectorAll("video");return Array.from(e).filter(o=>!ne(o))}function _i(t){try{const e=t.querySelector('[data-testid="User-Name"]');if(e){const n=e.querySelector('a[href^="/"]');if(n){const r=n.getAttribute("href");if(r&&r.startsWith("/")){const i=r.slice(1).split("/")[0];if(i)return i}}}const o=t.querySelector('a[href*="/status/"]');return o?he(o.href).userid:he(window.location.href).userid}catch{return}}function pi(t){let e=t;for(let o=0;o<20&&e;o++)if(e=e.parentElement,e?.tagName.toLowerCase()==="a")return e;return null}const qe=async({setIsDownloading:t,targetImage:e,settings:o,skipAutoLike:n=!1,imageIndex:r,isShiftPressed:i=!1,tweetContainer:s})=>{t(!0);const{picname:a,ext:d}=ko(e.src);let c;if(window.location.href.includes("photo"))c=he(window.location.href);else{const p=pi(e);if(!p)return;c=he(p.href)}const f=r||parseInt(c.picno)-1,l=St(o.fileName,{Userid:c.userid,Tid:c.tid,Time:`${Date.now()}`,PicName:a,PicNo:`${f}`}),_=`https://pbs.twimg.com/media/${a}?format=${d}&name=orig`;try{if(i){await $t(_);return}if(await xt(_,`${l}.${d}`),o.autoLikeOnDownload&&c.tid&&!n){const p=await jt(s,c.tid);!p.success&&p.message&&E.error(p.message)}}catch(p){Kt(p,m.t("messages.imageDownloadFailed"))}finally{t(!1)}};function hi({targetImage:t,tweetContainer:e}){const{settings:o}=Se(),[n,r]=I(!1);return o.showDownloadButton?u(Wt,{isDownloading:n,onClick:(i,s)=>qe({setIsDownloading:r,targetImage:t,settings:o,isShiftPressed:s,tweetContainer:e}),title:m.t("ui.downloadImage"),style:Gt(o)}):null}const Qt=async({setIsDownloading:t,src:e,tweetContainer:o,settings:n,skipAutoLike:r=!1,isShiftPressed:i=!1})=>{t(!0);try{const s=_i(o),a=di(o,s);if(!a){E.error(m.t("messages.cannotRecognizeTweet"));return}const d=e&&e.startsWith("https://video.twimg.com")?e:await Zn(a);if(!d){E.error(m.t("messages.videoLinkNotFound"));return}if(i){await $t(d);return}const c={userid:s,tid:a},f=St(n.videoFileName,{Userid:c.userid||"unknown",Tid:c.tid,Time:`${Date.now()}`});if(await xt(d,`${f}.mp4`),n.autoLikeOnDownload&&a&&!r){const l=await jt(o,a);!l.success&&l.message&&E.error(l.message)}}catch(s){Kt(s,m.t("messages.videoDownloadFailed"))}finally{t(!1)}};function mi({src:t,tweetContainer:e}){const{settings:o}=Se(),[n,r]=I(!1);return o.showVideoDownloadButton?u(Wt,{isDownloading:n,onClick:(i,s)=>Qt({setIsDownloading:r,src:t,tweetContainer:e,settings:o,isShiftPressed:s}),title:n?m.t("ui.downloading"):m.t("ui.downloadVideo"),style:Gt(o)}):null}const gi=T("button")` display: inline-flex; align-items: center; justify-content: center; width: 34.75px; height: 34.75px; border-radius: 50%; background: transparent; border: none; cursor: pointer; transition: background-color 0.2s ease; color: rgb(113, 118, 123); &:hover:not(:disabled) { background-color: rgba(29, 155, 240, 0.1); color: rgb(29, 155, 240); } &:disabled { cursor: not-allowed; opacity: 0.5; } `,vi=T("svg")` width: 18.75px; height: 18.75px; fill: currentColor; `;function wi({tweetContainer:t}){const{settings:e}=Se(),[o,n]=I(!1),[r,i]=I("none"),s=window.location.href;if(B(()=>{let _=null;const p=()=>{if(ui(t)){i("image");return}if(fi(t)){i("video");return}i("none")},h=()=>{_!==null&&clearTimeout(_),_=setTimeout(p,100)};p();const b=new MutationObserver(h);return b.observe(t,{childList:!0,subtree:!0,attributes:!1,characterData:!1}),()=>{b.disconnect(),_!==null&&clearTimeout(_)}},[t]),r==="none"||!e.showUniversalDownloadButton)return null;const a=()=>{},d=async _=>{if(s.includes("/photo/")&&_.nodeName!=="ARTICLE"){const g=s.match(/\/photo\/(\d+)/),C=g&&g[1]?parseInt(g[1])-1:0,D=_.querySelector('[aria-roledescription="carousel"]');if(D){const R=D.querySelectorAll(Xt)[C];if(R){await qe({setIsDownloading:a,targetImage:R,settings:e,imageIndex:C,tweetContainer:_}),E.success(m.t("messages.imagesDownloadSuccess",{count:1}));return}}throw new Error("Image not found in preview mode")}const h=Jt(_).map((g,C)=>g?qe({setIsDownloading:a,targetImage:g,settings:e,skipAutoLike:C>0,imageIndex:C,tweetContainer:_}):Promise.resolve()),b=await Promise.allSettled(h),x=b.filter(g=>g.status==="rejected"),w=b.length-x.length;w===0?E.error(m.t("messages.imageDownloadFailed")):x.length>0?E.warning(m.t("messages.imagesDownloadSuccess",{count:`${w}/${b.length}`})):E.success(m.t("messages.imagesDownloadSuccess",{count:b.length}))},c=async _=>{const h=Zt(_)[0];h&&Qt({setIsDownloading:a,src:h.src,tweetContainer:_,settings:e}).then(()=>E.success(m.t("messages.videoDownloadSuccess")))};return u(gi,{onClick:async _=>{if(!o){_.stopPropagation(),n(!0);try{r==="image"?await d(t):r==="video"&&await c(t)}finally{n(!1)}}},disabled:o,title:(()=>{if(o)return m.t("ui.downloading");let _=Jt(t).length,p=Zt(t).length;return["/photo/","/video/"].some(h=>s.includes(h))&&(_=1,p=1),r==="image"?_>1?m.t("ui.downloadImages",{count:_}):m.t("ui.downloadImage"):p>1?m.t("ui.downloadVideos",{count:p}):m.t("ui.downloadVideo")})(),children:u(vi,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:u("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"})})})}GM_registerMenuCommand("⚙️ Settings / 设置",()=>{window.dispatchEvent(new CustomEvent(Ve))});const Xt='img[src^="https://pbs.twimg.com/media/"]',yi="video",eo=new WeakSet,to=new WeakSet,oo=new WeakSet,no=()=>JSON.parse(localStorage.getItem(pe)||"{}"),io=(t,e,o)=>{const n=document.createElement("div");n.style.display="none",t.appendChild(n);const r=()=>{const i=no()[e]!==!1;n.style.display=i?"block":"none",i&&o(n)};o(n),t.addEventListener("mouseenter",r),t.addEventListener("mouseleave",()=>n.style.display="none")},bi=t=>{getComputedStyle(t).position==="static"&&(t.style.position="relative")};function ro(t){if(oo.has(t))return;const e=Array.from(t.querySelectorAll('div[role="group"]')).find(i=>{const s=i.getAttribute("aria-label");return s&&s.includes("likes")});if(!e)return;const o=document.createElement("div");o.style.cssText="display: inline-flex; align-items: center; margin-left: auto;",e.appendChild(o);const n=()=>J(u(wi,{tweetContainer:t}),o);n();let r=null;e.addEventListener("mouseenter",()=>{r&&clearTimeout(r),r=window.setTimeout(n,50)}),oo.add(t)}const so=t=>!!t.src&&t.src.startsWith("https://pbs.twimg.com/media/");function ao(t){if(eo.has(t)||!so(t))return;const e=Yt(t);e&&ro(e);const o=t.parentElement?.parentElement;o&&(bi(o),io(o,"showDownloadButton",n=>{J(u(hi,{targetImage:t,tweetContainer:e}),n)}),eo.add(t))}function lo(t){if(to.has(t)||ne(t))return;const e=Yt(t);if(!e)return;ro(e);const o=Qn(t)||Xn(t);o&&(io(o,"showVideoDownloadButton",n=>{J(u(mi,{src:t.src,tweetContainer:e}),n)}),to.add(t))}const xi=t=>{t instanceof HTMLImageElement&&so(t)?ao(t):t.firstChild instanceof HTMLVideoElement?lo(t.firstChild):(t instanceof Element||t instanceof Document||t instanceof DocumentFragment)&&(t.querySelectorAll(Xt).forEach(e=>ao(e)),t.querySelectorAll(yi).forEach(e=>lo(e)))};function Si(){const t=new Set;let e=null;const o=i=>{t.add(i),e===null&&(e=requestAnimationFrame(()=>{e=null,t.forEach(s=>{xi(s)}),t.clear()}))};o(document);const n=new MutationObserver(i=>{i.forEach(s=>{s.addedNodes.forEach(a=>{o(a)})})});n.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1});const r=()=>{n.disconnect(),e!==null&&(cancelAnimationFrame(e),e=null),t.clear()};window.addEventListener("beforeunload",r)}function ki(){const t="x-downloader-hide-edit-image";let e=document.getElementById(t);e||(e=document.createElement("style"),e.id=t,document.head.appendChild(e));const o=()=>{no().hideEditImageButton?e.textContent='a[aria-label="Edit image"] { display: none !important; }':e.textContent=""};o(),window.addEventListener(ze,o)}function co(){const t=document.createElement("div");t.id="x-downloader-app",document.body.appendChild(t),J(u(Ln,{}),t),ki(),Si()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",co):co()})();