@hanzo/browser-extension 1.9.72 → 1.9.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chrome/background.js +47 -41
- package/chrome/content-script.js +52 -38
- package/chrome/manifest.json +1 -1
- package/chrome/newtab.css +1 -1
- package/chrome/newtab.js +50 -50
- package/chrome/popup.css +616 -288
- package/chrome/popup.html +437 -470
- package/chrome/popup.js +16 -14
- package/chrome/sidebar.css +236 -134
- package/chrome/sidebar.html +39 -1
- package/chrome/sidebar.js +75 -74
- package/firefox/background.js +20 -14
- package/firefox/content-script.js +52 -38
- package/firefox/manifest.json +1 -1
- package/firefox/newtab.css +1 -1
- package/firefox/newtab.js +50 -50
- package/firefox/popup.css +616 -288
- package/firefox/popup.html +437 -470
- package/firefox/popup.js +16 -14
- package/firefox/sidebar.css +236 -134
- package/firefox/sidebar.html +39 -1
- package/firefox/sidebar.js +75 -74
- package/package.json +1 -1
package/chrome/content-script.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";(()=>{var J=Object.create;var W=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var se=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var re=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of te(e))!oe.call(o,s)&&s!==t&&W(o,s,{get:()=>e[s],enumerable:!(n=ee(e,s))||n.enumerable});return o};var ie=(o,e,t)=>(t=o!=null?J(ne(o)):{},re(e||!o||!o.__esModule?W(t,"default",{value:o,enumerable:!0}):t,o));var K=se((B,F)=>{(function(o,e){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],e);else if(typeof B<"u")e(F);else{var t={exports:{}};e(t),o.browser=t.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:B,function(o){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)o.exports=globalThis.browser;else{let e="The message port closed before a response was received.",t=n=>{let s={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(s).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class i extends WeakMap{constructor(a,d=void 0){super(d),this.createItem=a}get(a){return this.has(a)||this.set(a,this.createItem(a)),super.get(a)}}let l=r=>r&&typeof r=="object"&&typeof r.then=="function",u=(r,a)=>(...d)=>{n.runtime.lastError?r.reject(new Error(n.runtime.lastError.message)):a.singleCallbackArg||d.length<=1&&a.singleCallbackArg!==!1?r.resolve(d[0]):r.resolve(d)},c=r=>r==1?"argument":"arguments",g=(r,a)=>function(m,...f){if(f.length<a.minArgs)throw new Error(`Expected at least ${a.minArgs} ${c(a.minArgs)} for ${r}(), got ${f.length}`);if(f.length>a.maxArgs)throw new Error(`Expected at most ${a.maxArgs} ${c(a.maxArgs)} for ${r}(), got ${f.length}`);return new Promise((v,w)=>{if(a.fallbackToNoCallback)try{m[r](...f,u({resolve:v,reject:w},a))}catch(h){console.warn(`${r} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,h),m[r](...f),a.fallbackToNoCallback=!1,a.noCallback=!0,v()}else a.noCallback?(m[r](...f),v()):m[r](...f,u({resolve:v,reject:w},a))})},x=(r,a,d)=>new Proxy(a,{apply(m,f,v){return d.call(f,r,...v)}}),E=Function.call.bind(Object.prototype.hasOwnProperty),p=(r,a={},d={})=>{let m=Object.create(null),f={has(w,h){return h in r||h in m},get(w,h,T){if(h in m)return m[h];if(!(h in r))return;let A=r[h];if(typeof A=="function")if(typeof a[h]=="function")A=x(r,r[h],a[h]);else if(E(d,h)){let C=g(h,d[h]);A=x(r,r[h],C)}else A=A.bind(r);else if(typeof A=="object"&&A!==null&&(E(a,h)||E(d,h)))A=p(A,a[h],d[h]);else if(E(d,"*"))A=p(A,a[h],d["*"]);else return Object.defineProperty(m,h,{configurable:!0,enumerable:!0,get(){return r[h]},set(C){r[h]=C}}),A;return m[h]=A,A},set(w,h,T,A){return h in m?m[h]=T:r[h]=T,!0},defineProperty(w,h,T){return Reflect.defineProperty(m,h,T)},deleteProperty(w,h){return Reflect.deleteProperty(m,h)}},v=Object.create(r);return new Proxy(v,f)},b=r=>({addListener(a,d,...m){a.addListener(r.get(d),...m)},hasListener(a,d){return a.hasListener(r.get(d))},removeListener(a,d){a.removeListener(r.get(d))}}),y=new i(r=>typeof r!="function"?r:function(d){let m=p(d,{},{getContent:{minArgs:0,maxArgs:0}});r(m)}),k=new i(r=>typeof r!="function"?r:function(d,m,f){let v=!1,w,h=new Promise(P=>{w=function(z){v=!0,P(z)}}),T;try{T=r(d,m,w)}catch(P){T=Promise.reject(P)}let A=T!==!0&&l(T);if(T!==!0&&!A&&!v)return!1;let C=P=>{P.then(z=>{f(z)},z=>{let N;z&&(z instanceof Error||typeof z.message=="string")?N=z.message:N="An unexpected error occurred",f({__mozWebExtensionPolyfillReject__:!0,message:N})}).catch(z=>{console.error("Failed to send onMessage rejected reply",z)})};return C(A?T:h),!0}),L=({reject:r,resolve:a},d)=>{n.runtime.lastError?n.runtime.lastError.message===e?a():r(new Error(n.runtime.lastError.message)):d&&d.__mozWebExtensionPolyfillReject__?r(new Error(d.message)):a(d)},S=(r,a,d,...m)=>{if(m.length<a.minArgs)throw new Error(`Expected at least ${a.minArgs} ${c(a.minArgs)} for ${r}(), got ${m.length}`);if(m.length>a.maxArgs)throw new Error(`Expected at most ${a.maxArgs} ${c(a.maxArgs)} for ${r}(), got ${m.length}`);return new Promise((f,v)=>{let w=L.bind(null,{resolve:f,reject:v});m.push(w),d.sendMessage(...m)})},_={devtools:{network:{onRequestFinished:b(y)}},runtime:{onMessage:b(k),onMessageExternal:b(k),sendMessage:S.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:S.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},H={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return s.privacy={network:{"*":H},services:{"*":H},websites:{"*":H}},p(n,_,s)};o.exports=t(chrome)}})});var fe=ie(K());var I="hanzo_shortcut_inspect",O={ctrl:!0,meta:!1,alt:!1,shift:!1,key:""};function D(o,e){return!(e.ctrl&&!o.ctrlKey||e.meta&&!o.metaKey||e.alt&&!o.altKey||e.shift&&!o.shiftKey||!e.ctrl&&o.ctrlKey||!e.meta&&o.metaKey||!e.alt&&o.altKey||!e.shift&&o.shiftKey||e.key&&(o.key||"").toLowerCase()!==e.key.toLowerCase())}async function j(o){try{let t=(await o.get([I]))[I];if(t&&typeof t=="object"&&typeof t.ctrl=="boolean"&&typeof t.alt=="boolean"&&typeof t.shift=="boolean"&&typeof t.meta=="boolean"&&typeof t.key=="string")return t}catch{}return{...O}}function ae(o){return o?Math.ceil(o.length/4):0}function V(o){return(o||[]).reduce((e,t)=>e+ae((t==null?void 0:t.content)||""),0)}function G(o,e,t){return o&&o!=="auto"?o:t<=900&&e.includes("zen5-flash")?"zen5-flash":"zen5"}var le=/embed|image|video|music|voice|tts|rerank|guard|foley|moderation|router/;function X(o){return o.filter(e=>(e==null?void 0:e.owned_by)==="zenlm"&&!le.test(e.id))}var U=class{constructor(){this.inspectShortcut={...O};this.loadShortcut(),this.watchShortcut(),this.setupClickHandler(),this.injectHelpers(),this.setupMessageHandlers(),this.syncHanzoWebAuth()}syncHanzoWebAuth(){try{let e=location.hostname.toLowerCase();if(!(e==="hanzo.ai"||e.endsWith(".hanzo.ai")||e==="hanzo.app"||e.endsWith(".hanzo.app")||e==="hanzo.chat"))return;if(location.pathname==="/callback"){let s=new URLSearchParams(location.search);if(s.has("code")||s.has("access_token")||s.has("error")){chrome.runtime.sendMessage({action:"auth.callback",url:location.href}).catch(()=>{});return}let i=new URLSearchParams(location.hash.replace(/^#/,""));if(i.get("email")&&i.get("code")){location.replace(`/auth/callback${location.search}${location.hash}`);return}}let n=(s=!1)=>{try{let i=localStorage.getItem("hanzo_iam_access_token");if(!i)return;let l=null;try{let u=localStorage.getItem("hanzo_iam_user");u&&(l=JSON.parse(u))}catch{}chrome.runtime.sendMessage({action:"auth.syncWebSession",force:s,tokens:{accessToken:i,refreshToken:localStorage.getItem("hanzo_iam_refresh_token"),idToken:localStorage.getItem("hanzo_iam_id_token"),expiresAt:localStorage.getItem("hanzo_iam_expires_at"),user:l}}).catch(()=>{})}catch{}};n(!1),window.addEventListener("storage",s=>{s.key==="hanzo_iam_access_token"&&s.newValue&&n(!0)})}catch{}}async loadShortcut(){try{this.inspectShortcut=await j(chrome.storage.local)}catch{this.inspectShortcut={...O}}}watchShortcut(){try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local")return;let n=e[I];n&&(n.newValue&&typeof n.newValue=="object"?this.inspectShortcut=n.newValue:this.inspectShortcut={...O})})}catch{}}setupClickHandler(){let e=t=>{if(!D(t,this.inspectShortcut))return;t.preventDefault(),t.stopPropagation();let n=t.target,s={event:"elementSelected",framework:this.detectFramework(),domPath:this.getDOMPath(n),source:this.extractSourceLocation(n),fallbackId:n.getAttribute("data-hanzo-id")||void 0};Q(n,s)};document.addEventListener("click",e,!0),document.addEventListener("contextmenu",e,!0)}setupMessageHandlers(){chrome.runtime.onMessage.addListener((e,t,n)=>{var s;switch(e.action){case"ai.control.start":return $.show(e.task||"AI is controlling this page"),n({success:!0}),!0;case"ai.control.stop":return $.hide(),n({success:!0}),!0;case"ai.control.cursor":return $.moveCursor(e.x,e.y),n({success:!0}),!0;case"ai.control.highlight":return $.highlight(e.selector),n({success:!0}),!0;case"ai.control.status":return $.updateStatus(e.text),n({success:!0}),!0;case"page.overlay.toggle":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),n({success:!0,open:M.toggle()}),!0;case"page.overlay.show":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),M.show(),n({success:!0,open:!0}),!0;case"page.overlay.hide":return M.hide(),n({success:!0,open:!1}),!0;case"page.overlay.status":return n({success:!0,open:M.isOpen(),side:M.getSide(),mode:M.getMode()}),!0;case"page.overlay.setSide":return e.side==="left"||e.side==="right"?(M.setSide(e.side),n({success:!0,side:e.side})):n({success:!1,error:'side must be "left" or "right"'}),!0;case"page.overlay.setMode":return e.mode==="push"||e.mode==="overlay"?(M.setMode(e.mode),n({success:!0,mode:e.mode})):n({success:!1,error:'mode must be "push" or "overlay"'}),!0;case"page.overlay.setWidth":return e.width==="compact"||e.width==="default"||e.width==="wide"?(M.setWidth(e.width),n({success:!0,width:e.width})):n({success:!1,error:"width must be compact|default|wide"}),!0;case"page.overlay.setEnabled":return typeof e.enabled=="boolean"?(M.setEnabled(e.enabled),n({success:!0,enabled:e.enabled})):n({success:!1,error:"enabled must be boolean"}),!0;case"tool.picker.start":return Z.start(),n({success:!0}),!0;case"tool.picker.stop":return Z.stop(),n({success:!0}),!0;case"tool.pageinfo":return n({success:!0,info:de()}),!0;case"tool.console.start":return q.show(),n({success:!0}),!0;case"tool.console.hide":return q.hide(),n({success:!0}),!0}return e.action==="getContent"?(n({content:((s=document.documentElement)==null?void 0:s.outerHTML)||""}),!0):e.action==="setContent"?(typeof e.content=="string"&&(document.open(),document.write(e.content),document.close()),n({success:!0}),!0):!1})}extractSourceLocation(e){switch(this.detectFramework()){case"react":return this.extractReactSource(e);case"vue":return this.extractVueSource(e);case"svelte":return this.extractSvelteSource(e);default:return}}extractReactSource(e){var i,l;if(!window.__REACT_DEVTOOLS_GLOBAL_HOOK__)return;let n=this.findReactFiber(e);if(!n)return;let s=n._debugSource||((i=n.pendingProps)==null?void 0:i.__source)||((l=n.memoizedProps)==null?void 0:l.__source);if(s&&s.fileName)return{file:s.fileName,line:s.lineNumber,column:s.columnNumber}}findReactFiber(e){let t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"));return t?e[t]:null}extractVueSource(e){var s,i;if(!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)return;let n=e.__vueParentComponent;if(n||(n=e.__vue__),(s=n==null?void 0:n.type)!=null&&s.__file){let l={file:n.type.__file,line:1};return(i=n.vnode)!=null&&i.loc&&(l.line=n.vnode.loc.start.line,l.column=n.vnode.loc.start.column),l}}extractSvelteSource(e){var n,s;let t=e.__svelte_component;if((s=(n=t==null?void 0:t.$$)==null?void 0:n.ctx)!=null&&s.$$_location)return t.$$.ctx.$$_location}detectFramework(){return window.__REACT_DEVTOOLS_GLOBAL_HOOK__?"react":window.__VUE_DEVTOOLS_GLOBAL_HOOK__?"vue":window.__svelte?"svelte":null}getDOMPath(e){let t=[],n=e;for(;n&&n!==document.body;){let s=n.tagName.toLowerCase();n.id?s+=`#${n.id}`:n.className&&(s+=`.${n.className.split(" ").join(".")}`),t.unshift(s),n=n.parentElement}return t.join(" > ")}injectHelpers(){let e=document.createElement("style");e.textContent=`
|
|
1
|
+
"use strict";(()=>{var te=Object.create;var W=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ie=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var ae=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of oe(e))!se.call(o,r)&&r!==t&&W(o,r,{get:()=>e[r],enumerable:!(n=ne(e,r))||n.enumerable});return o};var le=(o,e,t)=>(t=o!=null?te(re(o)):{},ae(e||!o||!o.__esModule?W(t,"default",{value:o,enumerable:!0}):t,o));var F=ie((N,K)=>{(function(o,e){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],e);else if(typeof N<"u")e(K);else{var t={exports:{}};e(t),o.browser=t.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:N,function(o){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)o.exports=globalThis.browser;else{let e="The message port closed before a response was received.",t=n=>{let r={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(r).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class i extends WeakMap{constructor(l,d=void 0){super(d),this.createItem=l}get(l){return this.has(l)||this.set(l,this.createItem(l)),super.get(l)}}let a=s=>s&&typeof s=="object"&&typeof s.then=="function",u=(s,l)=>(...d)=>{n.runtime.lastError?s.reject(new Error(n.runtime.lastError.message)):l.singleCallbackArg||d.length<=1&&l.singleCallbackArg!==!1?s.resolve(d[0]):s.resolve(d)},c=s=>s==1?"argument":"arguments",b=(s,l)=>function(g,...p){if(p.length<l.minArgs)throw new Error(`Expected at least ${l.minArgs} ${c(l.minArgs)} for ${s}(), got ${p.length}`);if(p.length>l.maxArgs)throw new Error(`Expected at most ${l.maxArgs} ${c(l.maxArgs)} for ${s}(), got ${p.length}`);return new Promise((A,E)=>{if(l.fallbackToNoCallback)try{g[s](...p,u({resolve:A,reject:E},l))}catch(h){console.warn(`${s} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,h),g[s](...p),l.fallbackToNoCallback=!1,l.noCallback=!0,A()}else l.noCallback?(g[s](...p),A()):g[s](...p,u({resolve:A,reject:E},l))})},f=(s,l,d)=>new Proxy(l,{apply(g,p,A){return d.call(p,s,...A)}}),w=Function.call.bind(Object.prototype.hasOwnProperty),m=(s,l={},d={})=>{let g=Object.create(null),p={has(E,h){return h in s||h in g},get(E,h,M){if(h in g)return g[h];if(!(h in s))return;let v=s[h];if(typeof v=="function")if(typeof l[h]=="function")v=f(s,s[h],l[h]);else if(w(d,h)){let C=b(h,d[h]);v=f(s,s[h],C)}else v=v.bind(s);else if(typeof v=="object"&&v!==null&&(w(l,h)||w(d,h)))v=m(v,l[h],d[h]);else if(w(d,"*"))v=m(v,l[h],d["*"]);else return Object.defineProperty(g,h,{configurable:!0,enumerable:!0,get(){return s[h]},set(C){s[h]=C}}),v;return g[h]=v,v},set(E,h,M,v){return h in g?g[h]=M:s[h]=M,!0},defineProperty(E,h,M){return Reflect.defineProperty(g,h,M)},deleteProperty(E,h){return Reflect.deleteProperty(g,h)}},A=Object.create(s);return new Proxy(A,p)},x=s=>({addListener(l,d,...g){l.addListener(s.get(d),...g)},hasListener(l,d){return l.hasListener(s.get(d))},removeListener(l,d){l.removeListener(s.get(d))}}),y=new i(s=>typeof s!="function"?s:function(d){let g=m(d,{},{getContent:{minArgs:0,maxArgs:0}});s(g)}),k=new i(s=>typeof s!="function"?s:function(d,g,p){let A=!1,E,h=new Promise(P=>{E=function(z){A=!0,P(z)}}),M;try{M=s(d,g,E)}catch(P){M=Promise.reject(P)}let v=M!==!0&&a(M);if(M!==!0&&!v&&!A)return!1;let C=P=>{P.then(z=>{p(z)},z=>{let D;z&&(z instanceof Error||typeof z.message=="string")?D=z.message:D="An unexpected error occurred",p({__mozWebExtensionPolyfillReject__:!0,message:D})}).catch(z=>{console.error("Failed to send onMessage rejected reply",z)})};return C(v?M:h),!0}),L=({reject:s,resolve:l},d)=>{n.runtime.lastError?n.runtime.lastError.message===e?l():s(new Error(n.runtime.lastError.message)):d&&d.__mozWebExtensionPolyfillReject__?s(new Error(d.message)):l(d)},S=(s,l,d,...g)=>{if(g.length<l.minArgs)throw new Error(`Expected at least ${l.minArgs} ${c(l.minArgs)} for ${s}(), got ${g.length}`);if(g.length>l.maxArgs)throw new Error(`Expected at most ${l.maxArgs} ${c(l.maxArgs)} for ${s}(), got ${g.length}`);return new Promise((p,A)=>{let E=L.bind(null,{resolve:p,reject:A});g.push(E),d.sendMessage(...g)})},_={devtools:{network:{onRequestFinished:x(y)}},runtime:{onMessage:x(k),onMessageExternal:x(k),sendMessage:S.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:S.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},H={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return r.privacy={network:{"*":H},services:{"*":H},websites:{"*":H}},m(n,_,r)};o.exports=t(chrome)}})});var ye=le(F());var I="hanzo_shortcut_inspect",O={ctrl:!0,meta:!1,alt:!1,shift:!1,key:""};function B(o,e){return!(e.ctrl&&!o.ctrlKey||e.meta&&!o.metaKey||e.alt&&!o.altKey||e.shift&&!o.shiftKey||!e.ctrl&&o.ctrlKey||!e.meta&&o.metaKey||!e.alt&&o.altKey||!e.shift&&o.shiftKey||e.key&&(o.key||"").toLowerCase()!==e.key.toLowerCase())}async function j(o){try{let t=(await o.get([I]))[I];if(t&&typeof t=="object"&&typeof t.ctrl=="boolean"&&typeof t.alt=="boolean"&&typeof t.shift=="boolean"&&typeof t.meta=="boolean"&&typeof t.key=="string")return t}catch{}return{...O}}function ce(o){return o?Math.ceil(o.length/4):0}function V(o){return(o||[]).reduce((e,t)=>e+ce((t==null?void 0:t.content)||""),0)}var de=/^(zen[45]|qwen2)/i;function G(o){return de.test((o||"").trim())}function X(o,e,t){return o&&o!=="auto"?G(o)?e.includes("enso")?"enso":"zen6":o:t<=900&&e.includes("zen6-flash")?"zen6-flash":e.includes("zen6")?"zen6":e.includes("enso")?"enso":"zen6"}var ue=/embed|image|video|music|voice|tts|rerank|guard|foley|moderation|router/;function Y(o){return o.filter(e=>(e==null?void 0:e.owned_by)==="zenlm"&&!ue.test(e.id)&&!G(e.id))}var R=class{constructor(){this.inspectShortcut={...O};this.loadShortcut(),this.watchShortcut(),this.setupClickHandler(),this.injectHelpers(),this.setupMessageHandlers(),this.syncHanzoWebAuth()}syncHanzoWebAuth(){try{let e=location.hostname.toLowerCase();if(!(e==="hanzo.ai"||e.endsWith(".hanzo.ai")||e==="hanzo.app"||e.endsWith(".hanzo.app")||e==="hanzo.chat"))return;if(location.pathname==="/callback"){let r=new URLSearchParams(location.search);if(r.has("code")||r.has("access_token")||r.has("error")){chrome.runtime.sendMessage({action:"auth.callback",url:location.href}).catch(()=>{});return}let i=new URLSearchParams(location.hash.replace(/^#/,""));if(i.get("email")&&i.get("code")){location.replace(`/auth/callback${location.search}${location.hash}`);return}}let n=(r=!1)=>{try{let i=localStorage.getItem("hanzo_iam_access_token");if(!i)return;let a=null;try{let u=localStorage.getItem("hanzo_iam_user");u&&(a=JSON.parse(u))}catch{}chrome.runtime.sendMessage({action:"auth.syncWebSession",force:r,tokens:{accessToken:i,refreshToken:localStorage.getItem("hanzo_iam_refresh_token"),idToken:localStorage.getItem("hanzo_iam_id_token"),expiresAt:localStorage.getItem("hanzo_iam_expires_at"),user:a}}).catch(()=>{})}catch{}};n(!1),window.addEventListener("storage",r=>{r.key==="hanzo_iam_access_token"&&r.newValue&&n(!0)})}catch{}}async loadShortcut(){try{this.inspectShortcut=await j(chrome.storage.local)}catch{this.inspectShortcut={...O}}}watchShortcut(){try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local")return;let n=e[I];n&&(n.newValue&&typeof n.newValue=="object"?this.inspectShortcut=n.newValue:this.inspectShortcut={...O})})}catch{}}setupClickHandler(){let e=t=>{if(!B(t,this.inspectShortcut))return;t.preventDefault(),t.stopPropagation();let n=t.target,r={event:"elementSelected",framework:this.detectFramework(),domPath:this.getDOMPath(n),source:this.extractSourceLocation(n),fallbackId:n.getAttribute("data-hanzo-id")||void 0};ee(n,r)};document.addEventListener("click",e,!0),document.addEventListener("contextmenu",e,!0)}setupMessageHandlers(){chrome.runtime.onMessage.addListener((e,t,n)=>{var r;switch(e.action){case"ai.control.start":return $.show(e.task||"AI is controlling this page"),n({success:!0}),!0;case"ai.control.stop":return $.hide(),n({success:!0}),!0;case"ai.control.cursor":return $.moveCursor(e.x,e.y),n({success:!0}),!0;case"ai.control.highlight":return $.highlight(e.selector),n({success:!0}),!0;case"ai.control.status":return $.updateStatus(e.text),n({success:!0}),!0;case"page.overlay.toggle":return(e.side==="left"||e.side==="right")&&T.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&T.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&T.setWidth(e.width),n({success:!0,open:T.toggle()}),!0;case"page.overlay.show":return(e.side==="left"||e.side==="right")&&T.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&T.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&T.setWidth(e.width),T.show(),n({success:!0,open:!0}),!0;case"page.overlay.hide":return T.hide(),n({success:!0,open:!1}),!0;case"page.overlay.status":return n({success:!0,open:T.isOpen(),side:T.getSide(),mode:T.getMode()}),!0;case"page.overlay.setSide":return e.side==="left"||e.side==="right"?(T.setSide(e.side),n({success:!0,side:e.side})):n({success:!1,error:'side must be "left" or "right"'}),!0;case"page.overlay.setMode":return e.mode==="push"||e.mode==="overlay"?(T.setMode(e.mode),n({success:!0,mode:e.mode})):n({success:!1,error:'mode must be "push" or "overlay"'}),!0;case"page.overlay.setWidth":return e.width==="compact"||e.width==="default"||e.width==="wide"?(T.setWidth(e.width),n({success:!0,width:e.width})):n({success:!1,error:"width must be compact|default|wide"}),!0;case"page.overlay.setEnabled":return typeof e.enabled=="boolean"?(T.setEnabled(e.enabled),n({success:!0,enabled:e.enabled})):n({success:!1,error:"enabled must be boolean"}),!0;case"tool.picker.start":return Q.start(),n({success:!0}),!0;case"tool.picker.stop":return Q.stop(),n({success:!0}),!0;case"tool.pageinfo":return n({success:!0,info:ge()}),!0;case"tool.console.start":return J.show(),n({success:!0}),!0;case"tool.console.hide":return J.hide(),n({success:!0}),!0}return e.action==="getContent"?(n({content:((r=document.documentElement)==null?void 0:r.outerHTML)||""}),!0):e.action==="setContent"?(typeof e.content=="string"&&(document.open(),document.write(e.content),document.close()),n({success:!0}),!0):!1})}extractSourceLocation(e){switch(this.detectFramework()){case"react":return this.extractReactSource(e);case"vue":return this.extractVueSource(e);case"svelte":return this.extractSvelteSource(e);default:return}}extractReactSource(e){var i,a;if(!window.__REACT_DEVTOOLS_GLOBAL_HOOK__)return;let n=this.findReactFiber(e);if(!n)return;let r=n._debugSource||((i=n.pendingProps)==null?void 0:i.__source)||((a=n.memoizedProps)==null?void 0:a.__source);if(r&&r.fileName)return{file:r.fileName,line:r.lineNumber,column:r.columnNumber}}findReactFiber(e){let t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"));return t?e[t]:null}extractVueSource(e){var r,i;if(!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)return;let n=e.__vueParentComponent;if(n||(n=e.__vue__),(r=n==null?void 0:n.type)!=null&&r.__file){let a={file:n.type.__file,line:1};return(i=n.vnode)!=null&&i.loc&&(a.line=n.vnode.loc.start.line,a.column=n.vnode.loc.start.column),a}}extractSvelteSource(e){var n,r;let t=e.__svelte_component;if((r=(n=t==null?void 0:t.$$)==null?void 0:n.ctx)!=null&&r.$$_location)return t.$$.ctx.$$_location}detectFramework(){return window.__REACT_DEVTOOLS_GLOBAL_HOOK__?"react":window.__VUE_DEVTOOLS_GLOBAL_HOOK__?"vue":window.__svelte?"svelte":null}getDOMPath(e){let t=[],n=e;for(;n&&n!==document.body;){let r=n.tagName.toLowerCase();n.id?r+=`#${n.id}`:n.className&&(r+=`.${n.className.split(" ").join(".")}`),t.unshift(r),n=n.parentElement}return t.join(" > ")}injectHelpers(){let e=document.createElement("style");e.textContent=`
|
|
2
2
|
[data-hanzo-hover] {
|
|
3
3
|
outline: 2px dashed #ff6b6b !important;
|
|
4
4
|
outline-offset: 2px !important;
|
|
5
5
|
}
|
|
6
|
-
`,document.head.appendChild(e),document.addEventListener("mousemove",t=>{document.querySelectorAll("[data-hanzo-hover]").forEach(n=>{n.removeAttribute("data-hanzo-hover")}),
|
|
6
|
+
`,document.head.appendChild(e),document.addEventListener("mousemove",t=>{document.querySelectorAll("[data-hanzo-hover]").forEach(n=>{n.removeAttribute("data-hanzo-hover")}),B(t,this.inspectShortcut)&&t.target instanceof HTMLElement&&t.target.setAttribute("data-hanzo-hover","true")})}},$=(()=>{let o=null,e=null,t=null,n=null,r=null,i=[],a=!1,u="hanzo-ai-overlay",c="hanzo-ai-overlay-styles",b=["click","dblclick","mousedown","mouseup","contextmenu","pointerdown","pointerup","touchstart","touchmove","touchend","wheel","keydown","keyup","keypress"];function f(){if(document.getElementById(c))return;let s=document.createElement("style");s.id=c,s.textContent=`
|
|
7
7
|
/* ---- Overlay backdrop ---- */
|
|
8
8
|
#${u} {
|
|
9
9
|
position: fixed;
|
|
@@ -217,12 +217,12 @@
|
|
|
217
217
|
box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
|
|
218
218
|
transition: left 0.15s, top 0.15s, width 0.15s, height 0.15s;
|
|
219
219
|
}
|
|
220
|
-
`,document.head.appendChild(
|
|
220
|
+
`,document.head.appendChild(s)}function w(s){return s instanceof Node?!!(o!=null&&o.contains(s)||t!=null&&t.contains(s)||n!=null&&n.contains(s)||e!=null&&e.contains(s)||r!=null&&r.contains(s)):!1}function m(s){if(a){if(s instanceof KeyboardEvent&&s.key==="Escape"){chrome.runtime.sendMessage({action:"ai.control.cancel"}),k();return}w(s.target)||(s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation())}}function x(s){if(a!==s){a=s;for(let l of b)s?document.addEventListener(l,m,!0):document.removeEventListener(l,m,!0)}}function y(s){var l;o&&k(),f(),x(!0),o=document.createElement("div"),o.id=u,document.body.appendChild(o),e=document.createElement("div"),e.className="hanzo-ai-cursor",e.style.left=`${window.innerWidth/2}px`,e.style.top=`${window.innerHeight/2}px`,document.body.appendChild(e),t=document.createElement("div"),t.className="hanzo-ai-status",t.innerHTML=`
|
|
221
221
|
<span class="hanzo-brand-bubble">AI</span>
|
|
222
222
|
<div class="hanzo-pulse-dot"></div>
|
|
223
|
-
<span class="hanzo-label">${H(
|
|
223
|
+
<span class="hanzo-label">${H(s||"Hanzo AI is controlling this tab")}</span><span class="hanzo-dots"></span>
|
|
224
224
|
<button class="hanzo-stop-btn">Stop</button>
|
|
225
|
-
`,document.body.appendChild(t),(
|
|
225
|
+
`,document.body.appendChild(t),(l=t.querySelector(".hanzo-stop-btn"))==null||l.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),k()}),n=document.createElement("button"),n.className="hanzo-ai-cancel",n.textContent="Take Back Control",n.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),k()}),document.body.appendChild(n),requestAnimationFrame(()=>{o==null||o.classList.add("hanzo-visible"),e==null||e.classList.add("hanzo-visible"),t==null||t.classList.add("hanzo-visible"),n==null||n.classList.add("hanzo-visible")})}function k(){o==null||o.classList.remove("hanzo-visible"),e==null||e.classList.remove("hanzo-visible"),t==null||t.classList.remove("hanzo-visible"),n==null||n.classList.remove("hanzo-visible");let s={overlay:o,cursor:e,statusEl:t,cancelBtn:n,highlightEl:r},l=[...i];setTimeout(()=>{var d,g,p,A,E;(d=s.overlay)==null||d.remove(),(g=s.cursor)==null||g.remove(),(p=s.statusEl)==null||p.remove(),(A=s.cancelBtn)==null||A.remove(),(E=s.highlightEl)==null||E.remove();for(let h of l)h.remove()},320),x(!1),o=null,e=null,t=null,n=null,r=null,i=[]}function L(s,l){var A;if(!e)return;let d=Math.max(0,Math.min(window.innerWidth,Number.isFinite(s)?s:0)),g=Math.max(0,Math.min(window.innerHeight,Number.isFinite(l)?l:0)),p=document.createElement("div");for(p.className="hanzo-cursor-trail",p.style.left=`${d}px`,p.style.top=`${g}px`,document.body.appendChild(p),i.push(p),setTimeout(()=>{p.remove(),i=i.filter(E=>E!==p)},400);i.length>10;)(A=i.shift())==null||A.remove();e.style.left=`${d}px`,e.style.top=`${g}px`}function S(s){if(r==null||r.remove(),r=null,!(!s||typeof s!="string"))try{let l=document.querySelector(s);if(!l)return;let d=l.getBoundingClientRect();if(d.width===0&&d.height===0)return;r=document.createElement("div"),r.className="hanzo-ai-highlight",r.style.left=`${Math.max(0,d.left-4)}px`,r.style.top=`${Math.max(0,d.top-4)}px`,r.style.width=`${d.width+8}px`,r.style.height=`${d.height+8}px`,document.body.appendChild(r)}catch{}}function _(s){if(!t)return;let l=t.querySelector(".hanzo-label");l&&(l.textContent=s||"Hanzo AI is controlling this tab")}function H(s){let l=document.createElement("div");return l.textContent=s,l.innerHTML}return{show:y,hide:k,moveCursor:L,highlight:S,updateStatus:_}})(),Z="Ask about this page, or tell me what to do on it. Watch inspects elements; Edit changes text in place.",q={compact:320,default:420,wide:560},U=class{constructor(){this.mounted=!1;this.enabled=!1;this.open=!1;this.side="right";this.mode="overlay";this.width="default";this.sending=!1;this.watchMode=!1;this.editMode=!1;this.modelsLoaded=!1;this.agent=null;this.selectedContext=null;this.hoveredElement=null;this.editingElement=null;this.root=null;this.launcher=null;this.panel=null;this.messagesEl=null;this.inputEl=null;this.sendBtn=null;this.modelEl=null;this.contextEl=null;this.watchBtn=null;this.editBtn=null;this.statusEl=null;this.highlightBox=null;this.injectStyles(),this.mount(),this.bindGlobalEvents(),this.restorePrefs()}restorePrefs(){var e,t;try{let n=(t=(e=typeof browser<"u"?browser:chrome)==null?void 0:e.storage)==null?void 0:t.sync;if(!(n!=null&&n.get))return;let r=n.get(["overlaySide","overlayMode","overlayWidth"]),i=a=>{var u,c;((a==null?void 0:a.overlaySide)==="left"||(a==null?void 0:a.overlaySide)==="right")&&(this.side=a.overlaySide,(u=this.root)==null||u.setAttribute("data-side",this.side)),((a==null?void 0:a.overlayMode)==="push"||(a==null?void 0:a.overlayMode)==="overlay")&&(this.mode=a.overlayMode,(c=this.root)==null||c.setAttribute("data-mode",this.mode)),((a==null?void 0:a.overlayWidth)==="compact"||(a==null?void 0:a.overlayWidth)==="default"||(a==null?void 0:a.overlayWidth)==="wide")&&(this.width=a.overlayWidth,this.applyWidth()),this.applyPushIfOpen()};r&&typeof r.then=="function"?r.then(i).catch(()=>{}):n.get(["overlaySide","overlayMode","overlayWidth"],i)}catch{}}applyWidth(){let e=q[this.width]??q.default;this.root&&(this.root.style.setProperty("--hanzo-overlay-width",`${e}px`),this.root.style.width=`min(${e}px, 100vw)`),document.documentElement.style.setProperty("--hanzo-overlay-width",`${e}px`)}applyPushIfOpen(){let e=document.documentElement;e.classList.remove("hanzo-overlay-push","hanzo-overlay-push-left","hanzo-overlay-push-right"),this.open&&this.enabled&&this.mode==="push"&&e.classList.add("hanzo-overlay-push",`hanzo-overlay-push-${this.side}`)}toggle(){return!this.enabled||!this.open?(this.show(),!0):(this.hide(),!1)}isOpen(){return this.open}getSide(){return this.side}getMode(){return this.mode}setSide(e){var t;this.side=e,(t=this.root)==null||t.setAttribute("data-side",e),this.applyPushIfOpen(),this.persist({overlaySide:e})}setMode(e){var t;this.mode=e,(t=this.root)==null||t.setAttribute("data-mode",e),this.applyPushIfOpen(),this.persist({overlayMode:e})}setWidth(e){this.width=e,this.applyWidth(),this.persist({overlayWidth:e})}setEnabled(e){var t;this.enabled=e,(t=this.root)==null||t.setAttribute("data-enabled",e?"true":"false"),e||this.hide(),this.persist({overlayEnabled:e})}persist(e){var t,n,r;try{let i=(n=(t=typeof browser<"u"?browser:chrome)==null?void 0:t.storage)==null?void 0:n.sync;(r=i==null?void 0:i.set)==null||r.call(i,e)}catch{}}show(){var e,t;this.ensureMounted(),this.enabled=!0,this.open=!0,(e=this.root)==null||e.setAttribute("data-enabled","true"),(t=this.root)==null||t.setAttribute("data-open","true"),this.applyPushIfOpen(),this.loadModels(),this.follow(),this.focusInput()}hide(){var e;this.open=!1,(e=this.root)==null||e.setAttribute("data-open","false"),this.applyPushIfOpen(),this.updateStatus(""),this.clearHighlight(),this.setWatchMode(!1),this.setEditMode(!1)}ensureMounted(){this.mounted||this.mount()}injectStyles(){if(document.getElementById("hanzo-page-overlay-styles"))return;let e=document.createElement("style");e.id="hanzo-page-overlay-styles",e.textContent=`
|
|
226
226
|
/* Edge-pinned sidebar panel \u2014 no FAB, opened from extension popup.
|
|
227
227
|
Hanzo brand: monochrome (white primary, neutral surfaces). No blue. */
|
|
228
228
|
#hanzo-page-overlay-root {
|
|
@@ -260,11 +260,11 @@
|
|
|
260
260
|
.hanzo-page-panel {
|
|
261
261
|
width: 100%;
|
|
262
262
|
height: 100%;
|
|
263
|
-
border-left: 1px solid rgba(255, 255, 255, 0.
|
|
264
|
-
background:
|
|
265
|
-
color: #
|
|
263
|
+
border-left: 1px solid rgba(255, 255, 255, 0.08);
|
|
264
|
+
background: #000000;
|
|
265
|
+
color: #fafafa;
|
|
266
266
|
overflow: hidden;
|
|
267
|
-
box-shadow: -22px 0 48px rgba(0, 0, 0, 0.
|
|
267
|
+
box-shadow: -22px 0 48px rgba(0, 0, 0, 0.65);
|
|
268
268
|
transform: translateX(100%);
|
|
269
269
|
opacity: 0;
|
|
270
270
|
pointer-events: none;
|
|
@@ -276,8 +276,8 @@
|
|
|
276
276
|
|
|
277
277
|
#hanzo-page-overlay-root[data-side="left"] .hanzo-page-panel {
|
|
278
278
|
border-left: none;
|
|
279
|
-
border-right: 1px solid rgba(255, 255, 255, 0.
|
|
280
|
-
box-shadow: 22px 0 48px rgba(0, 0, 0, 0.
|
|
279
|
+
border-right: 1px solid rgba(255, 255, 255, 0.08);
|
|
280
|
+
box-shadow: 22px 0 48px rgba(0, 0, 0, 0.65);
|
|
281
281
|
transform: translateX(-100%);
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -291,9 +291,10 @@
|
|
|
291
291
|
display: flex;
|
|
292
292
|
align-items: center;
|
|
293
293
|
justify-content: space-between;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
height: 44px;
|
|
295
|
+
padding: 0 12px;
|
|
296
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
|
297
|
+
background: #09090b;
|
|
297
298
|
flex-shrink: 0;
|
|
298
299
|
}
|
|
299
300
|
|
|
@@ -433,39 +434,53 @@
|
|
|
433
434
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
|
434
435
|
}
|
|
435
436
|
|
|
437
|
+
/* A step the agent took on the page: a line, not a bubble. */
|
|
438
|
+
.hanzo-page-msg.step {
|
|
439
|
+
align-self: flex-start;
|
|
440
|
+
padding: 0 4px;
|
|
441
|
+
font-family: ui-monospace, Menlo, monospace;
|
|
442
|
+
font-size: 11px;
|
|
443
|
+
color: rgba(255, 255, 255, 0.5);
|
|
444
|
+
}
|
|
445
|
+
|
|
436
446
|
/* Composer pinned to bottom of the panel. flex-shrink: 0 prevents
|
|
437
447
|
it from collapsing when the messages scroller grows. */
|
|
438
448
|
.hanzo-page-composer {
|
|
439
|
-
border-top: 1px solid rgba(255, 255, 255, 0.
|
|
449
|
+
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
|
440
450
|
padding: 10px 12px;
|
|
441
451
|
display: flex;
|
|
442
452
|
gap: 8px;
|
|
443
453
|
align-items: flex-end;
|
|
444
|
-
background:
|
|
454
|
+
background: #050505;
|
|
445
455
|
flex-shrink: 0;
|
|
446
456
|
}
|
|
447
457
|
|
|
448
458
|
.hanzo-page-composer textarea {
|
|
449
459
|
flex: 1;
|
|
450
460
|
min-height: 38px;
|
|
451
|
-
max-height:
|
|
461
|
+
max-height: 120px;
|
|
452
462
|
resize: none;
|
|
453
|
-
border-radius:
|
|
454
|
-
border: 1px solid rgba(255, 255, 255, 0.
|
|
455
|
-
background:
|
|
456
|
-
color: #
|
|
457
|
-
padding: 9px
|
|
458
|
-
font-size:
|
|
463
|
+
border-radius: 14px;
|
|
464
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
465
|
+
background: #0d0d10;
|
|
466
|
+
color: #fafafa;
|
|
467
|
+
padding: 9px 12px;
|
|
468
|
+
font-size: 13px;
|
|
469
|
+
outline: none;
|
|
459
470
|
}
|
|
460
471
|
|
|
461
|
-
|
|
472
|
+
.hanzo-page-composer textarea:focus {
|
|
473
|
+
border-color: rgba(255, 255, 255, 0.24);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/* Primary action: WHITE on pitch-black monochrome pill. */
|
|
462
477
|
.hanzo-page-composer button {
|
|
463
|
-
min-width:
|
|
464
|
-
height:
|
|
465
|
-
border-radius:
|
|
478
|
+
min-width: 60px;
|
|
479
|
+
height: 36px;
|
|
480
|
+
border-radius: 9999px;
|
|
466
481
|
border: 1px solid #ffffff;
|
|
467
482
|
background: #ffffff;
|
|
468
|
-
color: #
|
|
483
|
+
color: #000000;
|
|
469
484
|
font-weight: 600;
|
|
470
485
|
font-size: 12px;
|
|
471
486
|
cursor: pointer;
|
|
@@ -498,7 +513,7 @@
|
|
|
498
513
|
outline: 2px solid rgba(255, 255, 255, 0.92) !important;
|
|
499
514
|
outline-offset: 2px !important;
|
|
500
515
|
}
|
|
501
|
-
`,document.head.appendChild(e)}mount(){var t,n,
|
|
516
|
+
`,document.head.appendChild(e)}mount(){var t,n,r,i,a,u;if(this.mounted)return;this.root=document.createElement("div"),this.root.id="hanzo-page-overlay-root",this.root.setAttribute("data-open","false"),this.root.setAttribute("data-enabled","false"),this.root.setAttribute("data-side",this.side),this.root.setAttribute("data-mode",this.mode),this.applyWidth(),this.root.innerHTML=`
|
|
502
517
|
<div class="hanzo-page-panel" role="dialog" aria-label="Hanzo Page Assistant">
|
|
503
518
|
<div class="hanzo-page-header">
|
|
504
519
|
<div class="hanzo-page-brand">Hanzo</div>
|
|
@@ -523,18 +538,17 @@
|
|
|
523
538
|
</select>
|
|
524
539
|
</div>
|
|
525
540
|
<div class="hanzo-page-messages" data-role="messages">
|
|
526
|
-
<div class="hanzo-page-msg assistant"
|
|
541
|
+
<div class="hanzo-page-msg assistant">${Z}</div>
|
|
527
542
|
</div>
|
|
528
543
|
<div class="hanzo-page-composer">
|
|
529
|
-
<textarea data-role="input" rows="1" placeholder="Ask
|
|
530
|
-
<button data-role="send" type="button">
|
|
544
|
+
<textarea data-role="input" rows="1" placeholder="Ask anything\u2026"></textarea>
|
|
545
|
+
<button data-role="send" type="button">Send</button>
|
|
531
546
|
</div>
|
|
532
547
|
</div>
|
|
533
|
-
`,this.panel=this.root.querySelector(".hanzo-page-panel"),this.launcher=null,this.messagesEl=this.root.querySelector('[data-role="messages"]'),this.inputEl=this.root.querySelector('[data-role="input"]'),this.sendBtn=this.root.querySelector('[data-role="send"]'),this.modelEl=this.root.querySelector('[data-role="model"]'),this.contextEl=this.root.querySelector(".hanzo-page-context"),this.watchBtn=this.root.querySelector('[data-role="watch"]'),this.editBtn=this.root.querySelector('[data-role="edit"]'),this.statusEl=this.root.querySelector(".hanzo-page-status"),(t=this.root.querySelector('[data-role="close"]'))==null||t.addEventListener("click",()=>this.hide());let e=this.root.querySelector('[data-role="pin-mode"]');e==null||e.setAttribute("data-active",this.mode==="push"?"true":"false"),e==null||e.addEventListener("click",()=>{let c=this.mode==="push"?"overlay":"push";this.setMode(c),e.setAttribute("data-active",c==="push"?"true":"false")}),(n=this.watchBtn)==null||n.addEventListener("click",()=>this.setWatchMode(!this.watchMode)),(
|
|
534
|
-
`)}async askPageQuestion(){var
|
|
535
|
-
`)}
|
|
536
|
-
`)
|
|
537
|
-
`)}var q=(()=>{let o=null,e=null,t=null,n=!1;function s(){o||(o=document.createElement("div"),o.id="hanzo-console-root",o.style.cssText='position:fixed;bottom:20px;left:20px;right:20px;z-index:2147483646;font-family:Zen Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;font-size:12px;display:none;',o.innerHTML=`
|
|
548
|
+
`,this.panel=this.root.querySelector(".hanzo-page-panel"),this.launcher=null,this.messagesEl=this.root.querySelector('[data-role="messages"]'),this.inputEl=this.root.querySelector('[data-role="input"]'),this.sendBtn=this.root.querySelector('[data-role="send"]'),this.modelEl=this.root.querySelector('[data-role="model"]'),this.contextEl=this.root.querySelector(".hanzo-page-context"),this.watchBtn=this.root.querySelector('[data-role="watch"]'),this.editBtn=this.root.querySelector('[data-role="edit"]'),this.statusEl=this.root.querySelector(".hanzo-page-status"),(t=this.root.querySelector('[data-role="close"]'))==null||t.addEventListener("click",()=>this.hide());let e=this.root.querySelector('[data-role="pin-mode"]');e==null||e.setAttribute("data-active",this.mode==="push"?"true":"false"),e==null||e.addEventListener("click",()=>{let c=this.mode==="push"?"overlay":"push";this.setMode(c),e.setAttribute("data-active",c==="push"?"true":"false")}),(n=this.watchBtn)==null||n.addEventListener("click",()=>this.setWatchMode(!this.watchMode)),(r=this.editBtn)==null||r.addEventListener("click",()=>this.setEditMode(!this.editMode)),(i=this.sendBtn)==null||i.addEventListener("click",()=>this.askPageQuestion()),(a=this.inputEl)==null||a.addEventListener("keydown",c=>{let b=c.isComposing||c.key==="Process"||c.keyCode===229;c.key==="Enter"&&!b&&(c.metaKey||c.ctrlKey||!c.shiftKey&&!c.altKey)&&(c.preventDefault(),this.askPageQuestion())}),(u=this.inputEl)==null||u.addEventListener("input",()=>{this.inputEl&&(this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,110)}px`)}),document.documentElement.appendChild(this.root),this.mounted=!0}bindGlobalEvents(){document.addEventListener("mousemove",e=>this.onMouseMove(e),!0),document.addEventListener("click",e=>this.onDocumentClick(e),!0),document.addEventListener("keydown",e=>this.onKeyDown(e),!0)}onMouseMove(e){if(!this.watchMode)return;let t=this.getPageTarget(e.target);t&&(this.hoveredElement=t,this.showHighlight(t),this.selectedContext||this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)))}onDocumentClick(e){if(!this.watchMode&&!this.editMode)return;let t=this.getPageTarget(e.target);t&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.watchMode&&(this.selectedContext=this.captureElementContext(t),this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)),this.updateStatus("Element selected")),this.editMode&&(this.enableInlineEdit(t),this.updateStatus("Editing element")))}onKeyDown(e){if(e.key==="Escape"){if(this.editingElement){this.disableInlineEdit(this.editingElement,!1),this.updateStatus("Edit canceled"),e.preventDefault();return}this.open&&(this.hide(),e.preventDefault())}}getPageTarget(e){var t;return!(e instanceof HTMLElement)||(t=this.root)!=null&&t.contains(e)||!e.isConnected||e.tagName.toLowerCase()==="html"||e.tagName.toLowerCase()==="body"?null:e}setWatchMode(e){var t;this.watchMode=e,e&&this.setEditMode(!1),(t=this.watchBtn)==null||t.setAttribute("data-active",e?"true":"false"),e?this.updateStatus("Watch mode on"):(this.hoveredElement=null,this.clearHighlight(),!this.selectedContext&&this.contextEl&&(this.contextEl.textContent="Use Watch to inspect page elements."))}setEditMode(e){var t;this.editMode=e,e&&this.setWatchMode(!1),(t=this.editBtn)==null||t.setAttribute("data-active",e?"true":"false"),!e&&this.editingElement?this.disableInlineEdit(this.editingElement,!0):e&&this.updateStatus("Edit mode on")}enableInlineEdit(e){if(this.editingElement&&this.editingElement!==e&&this.disableInlineEdit(this.editingElement,!0),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){e.focus(),this.editingElement=e;return}e.hasAttribute("data-hanzo-original-html")||e.setAttribute("data-hanzo-original-html",e.innerHTML),e.setAttribute("contenteditable","true"),e.setAttribute("spellcheck","true"),e.setAttribute("data-hanzo-inline-editing","true"),e.focus(),this.editingElement=e;let t=r=>{r.key==="Escape"&&(this.disableInlineEdit(e,!1),this.updateStatus("Edit reverted")),r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),this.disableInlineEdit(e,!0),this.updateStatus("Edit applied"))},n=()=>{this.disableInlineEdit(e,!0),this.updateStatus("Edit applied")};e.addEventListener("keydown",t,{once:!0}),e.addEventListener("blur",n,{once:!0})}disableInlineEdit(e,t){if(!t){let n=e.getAttribute("data-hanzo-original-html");n!==null&&(e.innerHTML=n)}e.removeAttribute("contenteditable"),e.removeAttribute("spellcheck"),e.removeAttribute("data-hanzo-inline-editing"),e.removeAttribute("data-hanzo-original-html"),this.editingElement===e&&(this.editingElement=null)}showHighlight(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0){this.clearHighlight();return}this.highlightBox||(this.highlightBox=document.createElement("div"),this.highlightBox.className="hanzo-page-highlight",document.documentElement.appendChild(this.highlightBox)),this.highlightBox.style.left=`${Math.max(0,t.left-3)}px`,this.highlightBox.style.top=`${Math.max(0,t.top-3)}px`,this.highlightBox.style.width=`${t.width+6}px`,this.highlightBox.style.height=`${t.height+6}px`}clearHighlight(){var e;(e=this.highlightBox)==null||e.remove(),this.highlightBox=null}captureElementContext(e){let t=this.normalizeText(e.innerText||e.textContent||"");return{selector:this.buildSelector(e),tag:e.tagName.toLowerCase(),text:t.slice(0,800),html:e.outerHTML.slice(0,1200)}}buildSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e,r=0;for(;n&&r<6;){let i=n.tagName.toLowerCase();if(n.classList.length>0){let u=Array.from(n.classList).slice(0,2).join(".");u&&(i+=`.${u}`)}let a=n.parentElement;if(a){let u=Array.from(a.children).filter(c=>c.tagName===n.tagName);if(u.length>1){let c=u.indexOf(n)+1;i+=`:nth-of-type(${c})`}}t.unshift(i),n=a,r+=1}return t.join(" > ")}normalizeText(e){return e.replace(/\s+/g," ").trim()}getElementSummary(e){let t=this.captureElementContext(e);return`${t.tag} \u2022 ${t.selector}`}async loadModels(){if(!(this.modelsLoaded||!this.modelEl))try{let e=await chrome.runtime.sendMessage({action:"chat.listModels"});if(!(e!=null&&e.success)||!Array.isArray(e.models))return;for(let t of Y(e.models)){let n=document.createElement("option");n.value=t.id,n.textContent=t.name||t.id,this.modelEl.appendChild(n)}this.modelsLoaded=!0}catch{}}focusInput(){this.inputEl&&this.inputEl.focus()}follow(){if(this.agent)return;let e=chrome.runtime.connect({name:"agent"});this.agent=e,e.onMessage.addListener(t=>{(t==null?void 0:t.action)==="agent.update"&&t.state&&this.draw(t.state)}),e.onDisconnect.addListener(()=>{chrome.runtime.lastError,this.agent=null,this.open&&setTimeout(()=>this.follow(),500)})}draw(e){this.sending=e.busy,this.sendBtn&&(this.sendBtn.textContent=e.busy?"Stop":"Send"),this.updateStatus(e.busy?"Working\u2026":"Ready"),this.messagesEl&&(this.messagesEl.replaceChildren(...(e.turns.length?e.turns:[{id:"intro",role:"assistant",content:Z}]).map(t=>{let n=document.createElement("div");return n.className=`hanzo-page-msg ${t.role}`,n.textContent="error"in t&&t.error?`Error: ${t.error}`:t.content,n})),this.messagesEl.scrollTop=this.messagesEl.scrollHeight)}appendMessage(e,t){if(!this.messagesEl)return;let n=document.createElement("div");n.className=`hanzo-page-msg ${e}`,n.textContent=t,this.messagesEl.appendChild(n),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}updateStatus(e){this.statusEl&&(this.statusEl.textContent=e)}buildPageContext(){var r,i;let e=this.normalizeText(((i=(r=window.getSelection)==null?void 0:r.call(window))==null?void 0:i.toString())||""),t=[`URL: ${location.href}`,`Title: ${document.title||"Untitled"}`];e&&t.push(`TextSelection: ${e.slice(0,600)}`);let n=this.selectedContext||(this.hoveredElement?this.captureElementContext(this.hoveredElement):null);return n&&(t.push(`ElementSelector: ${n.selector}`),n.text&&t.push(`ElementText: ${n.text.slice(0,600)}`),t.push(`ElementHTML: ${n.html.slice(0,800)}`)),t.join(`
|
|
549
|
+
`)}async askPageQuestion(){var r,i;if(!this.inputEl)return;if(this.sending){chrome.runtime.sendMessage({action:"agent.stop"});return}let e=this.normalizeText(this.inputEl.value);if(!e)return;this.inputEl.value="",this.inputEl.style.height="auto";let t=Array.from(((r=this.modelEl)==null?void 0:r.options)||[],a=>a.value),n=X(((i=this.modelEl)==null?void 0:i.value)||"auto",t,V([{role:"user",content:e}]));try{let a=await chrome.runtime.sendMessage({action:"agent.send",text:e,model:n,context:this.buildPageContext()});if(!(a!=null&&a.success))throw new Error((a==null?void 0:a.error)||"The agent is not running")}catch(a){this.appendMessage("assistant",`Error: ${(a==null?void 0:a.message)||"Chat request failed"}`)}finally{this.focusInput()}}},T=new U;function ee(o,e){let t=Math.random().toString(36).slice(2)+Date.now().toString(36);o.setAttribute("data-hanzo-picked",t);let n=o.getBoundingClientRect();chrome.runtime.sendMessage({action:"elementSelected",token:t,data:e},r=>{var c,b,f,w,m;chrome.runtime.lastError;let i=r==null?void 0:r.record,a=((c=i==null?void 0:i.source)==null?void 0:c.at)||((b=i==null?void 0:i.components)==null?void 0:b[0])||(i==null?void 0:i.selector)||o.tagName.toLowerCase(),u=[`Picked ${a}`,i!=null&&i.selector?`Selector: ${i.selector}`:"",(f=i==null?void 0:i.source)!=null&&f.at?`Source: ${i.source.at}`:"",(w=i==null?void 0:i.components)!=null&&w.length?`Components: ${i.components.join(" < ")}`:"",i!=null&&i.text?`Text: "${String(i.text).slice(0,80)}"`:""].filter(Boolean).join(`
|
|
550
|
+
`);he(i?`Sent to agent \xB7 ${a}`:"Picked (agent not reachable)",n),(m=navigator.clipboard)==null||m.writeText(u).catch(()=>{})})}function he(o,e){var r;(r=document.getElementById("hanzo-pick-toast"))==null||r.remove();let t=document.createElement("div");t.id="hanzo-pick-toast",t.textContent=o;let n=e.bottom+8<window.innerHeight-32?e.bottom+8:Math.max(8,e.top-36);t.style.cssText=`position:fixed;z-index:2147483647;left:${Math.max(8,Math.min(e.left,window.innerWidth-420))}px;top:${n}px;max-width:400px;background:#000;color:#fff;font:12px/1.4 Zen Mono,Menlo,monospace;padding:6px 10px;border-radius:6px;box-shadow:0 2px 10px rgba(0,0,0,.4);pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`,document.documentElement.appendChild(t),setTimeout(()=>t.remove(),2600)}var Q=(()=>{let o=!1,e=null,t=null,n=null;function r(m){if(m.id)return`#${m.id}`;let x=m.tagName.toLowerCase(),y=Array.from(m.classList).filter(S=>!S.startsWith("hanzo-")).slice(0,3),k=x;if(y.length&&(k+=`.${y.join(".")}`),document.querySelectorAll(k).length>1){let S=m.parentElement;if(S){let _=Array.from(S.children).indexOf(m)+1;k+=`:nth-child(${_})`}}return k}function i(m){let x=[],y=m;for(;y&&y!==document.documentElement;)x.unshift(r(y)),y=y.parentElement;return x.join(" > ")}function a(){e||(e=document.createElement("div"),e.id="hanzo-picker-overlay",e.style.cssText="position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #fff;border-radius:3px;background:rgba(255,255,255,0.06);transition:all 0.1s ease;display:none;",t=document.createElement("div"),t.id="hanzo-picker-label",t.style.cssText="position:fixed;z-index:2147483647;pointer-events:none;background:#000;color:#fff;font:11px/1.4 Zen Mono,Menlo,monospace;padding:3px 8px;border-radius:4px;max-width:400px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:none;box-shadow:0 2px 8px rgba(0,0,0,0.4);",document.body.appendChild(e),document.body.appendChild(t))}function u(m){var k;if(!o)return;let x=m.target;if(!x||x===e||x===t||(k=x.id)!=null&&k.startsWith("hanzo-picker"))return;n=x;let y=x.getBoundingClientRect();if(e&&(e.style.display="block",e.style.top=y.top+"px",e.style.left=y.left+"px",e.style.width=y.width+"px",e.style.height=y.height+"px"),t){t.style.display="block",t.textContent=r(x);let L=y.top-28;t.style.top=(L>0?L:y.bottom+4)+"px",t.style.left=y.left+"px"}}function c(m){if(!o)return;m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation();let x=n||m.target;x&&(w(),ee(x,{selector:r(x),path:i(x)}))}function b(m){m.key==="Escape"&&(m.preventDefault(),w())}function f(){o||(o=!0,a(),document.addEventListener("mousemove",u,!0),document.addEventListener("click",c,!0),document.addEventListener("keydown",b,!0),document.body.style.cursor="crosshair")}function w(){o=!1,document.removeEventListener("mousemove",u,!0),document.removeEventListener("click",c,!0),document.removeEventListener("keydown",b,!0),document.body.style.cursor="",e&&(e.style.display="none"),t&&(t.style.display="none"),n=null}return{start:f,stop:w}})();function ge(){let o=c=>{var b;return((b=document.querySelector(`meta[name="${c}"], meta[property="${c}"]`))==null?void 0:b.getAttribute("content"))||""},e=[`Title: ${document.title}`,`URL: ${location.href}`,`Description: ${o("description")||o("og:description")}`,`Charset: ${document.characterSet}`,`Language: ${document.documentElement.lang||"unknown"}`,`Viewport: ${o("viewport")}`],t=[];window.__REACT_DEVTOOLS_GLOBAL_HOOK__&&t.push("React"),window.__VUE_DEVTOOLS_GLOBAL_HOOK__&&t.push("Vue"),window.__svelte&&t.push("Svelte"),window.__NEXT_DATA__&&t.push("Next.js"),window.__NUXT__&&t.push("Nuxt"),document.querySelector("[ng-version]")&&t.push("Angular"),t.length&&e.push(`Frameworks: ${t.join(", ")}`);let n=document.querySelectorAll("script[src]").length,r=document.querySelectorAll('link[rel="stylesheet"]').length,i=document.querySelectorAll("img").length,a=document.querySelectorAll("a[href]").length;e.push(`Resources: ${n} scripts, ${r} stylesheets, ${i} images, ${a} links`);let u=performance.getEntriesByType("navigation")[0];return u&&e.push(`Load: ${Math.round(u.loadEventEnd-u.startTime)}ms (DOM: ${Math.round(u.domContentLoadedEventEnd-u.startTime)}ms)`),e.filter(c=>!c.endsWith(": ")).join(`
|
|
551
|
+
`)}var J=(()=>{let o=null,e=null,t=null,n=!1;function r(){o||(o=document.createElement("div"),o.id="hanzo-console-root",o.style.cssText='position:fixed;bottom:20px;left:20px;right:20px;z-index:2147483646;font-family:Zen Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;font-size:12px;display:none;',o.innerHTML=`
|
|
538
552
|
<div style="background:rgba(0,0,0,0.92);backdrop-filter:blur(12px);border:1px solid rgba(255,255,255,0.15);border-radius:10px;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.5);">
|
|
539
553
|
<div id="hanzo-console-output" style="max-height:200px;overflow-y:auto;padding:8px 12px;color:#ccc;white-space:pre-wrap;word-break:break-all;"></div>
|
|
540
554
|
<div style="display:flex;align-items:center;border-top:1px solid rgba(255,255,255,0.1);padding:0 12px;">
|
|
@@ -543,4 +557,4 @@
|
|
|
543
557
|
<span style="color:#444;font-size:10px;margin-left:8px;">Esc to close</span>
|
|
544
558
|
</div>
|
|
545
559
|
</div>
|
|
546
|
-
`,document.body.appendChild(o),e=o.querySelector("#hanzo-console-input"),t=o.querySelector("#hanzo-console-output"),e==null||e.addEventListener("keydown",c=>{if(c.key==="Escape"){u();return}if(c.key!=="Enter"||!(e!=null&&e.value.trim()))return;let
|
|
560
|
+
`,document.body.appendChild(o),e=o.querySelector("#hanzo-console-input"),t=o.querySelector("#hanzo-console-output"),e==null||e.addEventListener("keydown",c=>{if(c.key==="Escape"){u();return}if(c.key!=="Enter"||!(e!=null&&e.value.trim()))return;let b=e.value.trim();e.value="",i(`> ${b}`,"#888");try{let f=(0,eval)(b);i(String(f),"#4CAF50")}catch(f){i((f==null?void 0:f.message)||String(f),"#F44336")}}))}function i(c,b){if(!t)return;let f=document.createElement("div");f.style.color=b,f.textContent=c,t.appendChild(f),t.scrollTop=t.scrollHeight}function a(){r(),o&&(o.style.display="block"),n=!0,setTimeout(()=>e==null?void 0:e.focus(),50)}function u(){o&&(o.style.display="none"),n=!1}return{show:a,hide:u,isVisible:()=>n}})();new R;try{let t=function(){var r,i,a,u,c,b;if(!o)try{o=((i=(r=browser==null?void 0:browser.runtime)==null?void 0:r.connect)==null?void 0:i.call(r,{name:"zap-keepalive"}))||((u=(a=chrome==null?void 0:chrome.runtime)==null?void 0:a.connect)==null?void 0:u.call(a,{name:"zap-keepalive"})),o&&(e=setInterval(()=>{try{o==null||o.postMessage({type:"ping",t:Date.now()})}catch{n()}},1e4),(b=(c=o.onDisconnect)==null?void 0:c.addListener)==null||b.call(c,f=>{var w,m;(w=chrome==null?void 0:chrome.runtime)==null||w.lastError,(m=browser==null?void 0:browser.runtime)==null||m.lastError,f==null||f.error,o==null||o.error,n()}))}catch{o=null}},n=function(){if(e&&(clearInterval(e),e=null),o){try{o.disconnect()}catch{}o=null}};me=t,pe=n;let o=null,e=null;t(),window.addEventListener("pagehide",()=>{n()}),window.addEventListener("pageshow",r=>{r.persisted&&t()})}catch{}var me,pe;})();
|
package/chrome/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Hanzo AI",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.73",
|
|
5
5
|
"description": "AI answer engine, search, and dev assistant — Hanzo AI in a new tab, address-bar search, source-cited answers, realtime news, WebGPU AI, and MCP.",
|
|
6
6
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxfXGh0lPUT5m04GKfjUwrLsV6pLaK3VcZuFRPogqAir2tzyLYnQPRtHynue9yvDyguIVnlkwvcwfDOYZrvH76zbw4s6onPBG8HqTKO6LQ9K3kdO1qBBkMMjdOgULQ1MrWThEbpU7NSTiwLYpEta/jAvrKRCAeKIlQE8p6htZmPy9aRUZuae66JgLcAlzD2vviX9sVB1asFABJVswL1RgZ55/8IzZaUrFjzOo9OHK4hmEOtudzkML+5silsAYdC+1BZugph2x94ai17YmZTCL1XyUa5Ke4q80cj+i9rOTgzhZs+mruyhL/AvNVOXilsgqCdNqSz77naWzC3pVGbxOewIDAQAB",
|
|
7
7
|
"permissions": [
|