diff --git a/.gitignore b/.gitignore index 6704566..adb2c19 100644 --- a/.gitignore +++ b/.gitignore @@ -80,7 +80,6 @@ typings/ # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ diff --git a/dist/history-background.mjs b/dist/history-background.mjs new file mode 100644 index 0000000..681806b --- /dev/null +++ b/dist/history-background.mjs @@ -0,0 +1 @@ +var ft=Object.create;var F=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var dt=(n,t)=>()=>(n&&(t=n(n=0)),t);var pt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),gt=(n,t)=>{for(var e in t)F(n,e,{get:t[e],enumerable:!0});},Tn=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ot(t))!lt.call(n,a)&&a!==e&&F(n,a,{get:()=>t[a],enumerable:!(r=ut(t,a))||r.enumerable});return n};var ht=(n,t,e)=>(e=n!=null?ft(ct(n)):{},Tn(t||!n||!n.__esModule?F(e,"default",{value:n,enumerable:!0}):e,n)),_t=n=>Tn(F({},"__esModule",{value:!0}),n);var kn=pt((R,P)=>{var Pn=200,yt="Expected a function",cn="__lodash_hash_undefined__",Y=1,E=2,ln=1/0,Ln=9007199254740991,K="[object Arguments]",en="[object Array]",En="[object Boolean]",Mn="[object Date]",Dn="[object Error]",Rn="[object Function]",wt="[object GeneratorFunction]",q="[object Map]",Nn="[object Number]",O="[object Object]",bn="[object Promise]",Un="[object RegExp]",B="[object Set]",Gn="[object String]",Hn="[object Symbol]",rn="[object WeakMap]",$n="[object ArrayBuffer]",W="[object DataView]",Tt="[object Float32Array]",bt="[object Float64Array]",vt="[object Int8Array]",At="[object Int16Array]",mt="[object Int32Array]",xt="[object Uint8Array]",Ct="[object Uint8ClampedArray]",St="[object Uint16Array]",It="[object Uint32Array]",Ot=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pt=/^\w*$/,Lt=/^\./,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mt=/[\\^$.*+?()[\]{}|]/g,Dt=/\\(\\)?/g,Rt=/^\[object .+?Constructor\]$/,Nt=/^(?:0|[1-9]\d*)$/,o={};o[Tt]=o[bt]=o[vt]=o[At]=o[mt]=o[xt]=o[Ct]=o[St]=o[It]=!0;o[K]=o[en]=o[$n]=o[En]=o[W]=o[Mn]=o[Dn]=o[Rn]=o[q]=o[Nn]=o[O]=o[Un]=o[B]=o[Gn]=o[rn]=!1;var Fn=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,m=Fn||Ut||Function("return this")(),Kn=typeof R=="object"&&R&&!R.nodeType&&R,vn=Kn&&typeof P=="object"&&P&&!P.nodeType&&P,Gt=vn&&vn.exports===Kn,An=Gt&&Fn.process,mn=function(){try{return An&&An.binding("util")}catch{}}(),xn=mn&&mn.isTypedArray;function Ht(n,t){var e=n?n.length:0;return !!e&&qt(n,t,0)>-1}function $t(n,t,e){for(var r=-1,a=n?n.length:0;++r-1}function ye(n,t){var e=this.__data__,r=Z(e,n);return r<0?e.push([n,t]):e[r][1]=t,this}T.prototype.clear=pe;T.prototype.delete=ge;T.prototype.get=he;T.prototype.has=_e;T.prototype.set=ye;function b(n){var t=-1,e=n?n.length:0;for(this.clear();++t=Pn){var l=t?null:We(n);if(l)return dn(l);s=!1,a=Jt,u=new G;}else u=t?[]:f;n:for(;++rf))return !1;var l=i.get(n);if(l&&i.get(t))return l==t;var c=-1,d=!0,p=a&Y?new G:void 0;for(i.set(n,t),i.set(t,n);++c-1&&n%1==0&&n-1&&n%1==0&&n<=Ln}function V(n){var t=typeof n;return !!n&&(t=="object"||t=="function")}function k(n){return !!n&&typeof n=="object"}function _n(n){return typeof n=="symbol"||k(n)&&M.call(n)==Hn}var tr=xn?Yt(xn):Ue;function er(n){return n==null?"":qe(n)}function rr(n,t,e){var r=n==null?void 0:Bn(n,t);return r===void 0?e:r}function ir(n,t){return n!=null&&Ze(n,t,Me)}function on(n){return jn(n)?Le(n):He(n)}function ar(n){return n}function sr(){}function fr(n){return z(n)?Wt(j(n)):Ke(n)}P.exports=ke;});var it={};gt(it,{filterItem:()=>ur,getRepo:()=>yn,isCode:()=>rt,isDiscussion:()=>et,isIssue:()=>nt,isPR:()=>tt,transformItem:()=>or});var nt,tt,et,rt,yn,ur,or,at=dt(()=>{nt=n=>/\/issues\/\d+/.test(n),tt=n=>/\/pull\/\d+/.test(n),et=n=>/\/discussions\/\d+/.test(n),rt=n=>/github.com\/.+\/.+\/blob\/.+/.test(n),yn=n=>{let t=n.match(/https:\/\/github.com\/([^\/]+\/[^\/]+)/);return t&&t[1]},ur=(n,t)=>n.filter(e=>{if(!t)return !!yn(e.url);let{keyword:r,type:a}=t,i=r.toLocaleLowerCase();if(r&&e.url.toLocaleLowerCase().indexOf(i)<0&&e.title.toLocaleLowerCase().indexOf(i)<0)return !1;let s=a.toLocaleLowerCase();return s==="all"?!0:!!e[s]}),or=n=>n.map(t=>({...t,issue:nt(t.url),pr:tt(t.url),discussions:et(t.url),code:rt(t.url),repo:yn(t.url)}));});var st=ht(kn()),{transformItem:cr,filterItem:lr}=(at(),_t(it)),dr=7*24*3600*1e3,pr=()=>new Promise(n=>{chrome.history.search({text:"https://github.com",maxResults:200,startTime:dr},n);}),gr=()=>{chrome.runtime.onMessage.addListener(function(n,t,e){if(n.type=="history-query")return pr().then(r=>e(cr((0, st.default)(lr(r),"url")))),!0}),chrome.action.onClicked.addListener(n=>{chrome.tabs.sendMessage(n.id,{type:"history-modal"});}),chrome.commands.onCommand.addListener(n=>{n==="history-modal"&&chrome.tabs.query({currentWindow:!0,active:!0},function(t){let e=t[0];chrome.tabs.sendMessage(e.id,{type:"history-modal"});});});};gr(); diff --git a/dist/history-popup.mjs b/dist/history-popup.mjs new file mode 100644 index 0000000..a0eb517 --- /dev/null +++ b/dist/history-popup.mjs @@ -0,0 +1 @@ +function n(){chrome.tabs.query({currentWindow:!0,active:!0},function(e){let t=e[0];chrome.tabs.sendMessage(t.id,{type:"history-modal"});});}document.addEventListener("DOMContentLoaded",function(){n();}); diff --git a/dist/history.mjs b/dist/history.mjs new file mode 100644 index 0000000..4427411 --- /dev/null +++ b/dist/history.mjs @@ -0,0 +1,25 @@ +var u=e=>{let t=e.match(/https:\/\/github.com\/([^\/]+\/[^\/]+)/);return t&&t[1]},h=(e,t)=>e.filter(s=>{if(!t)return !!u(s.url);let{keyword:i,type:n}=t,r=i.toLocaleLowerCase();if(i&&s.url.toLocaleLowerCase().indexOf(r)<0&&s.title.toLocaleLowerCase().indexOf(r)<0)return !1;let c=n.toLocaleLowerCase();return c==="all"?!0:!!s[c]});var d=class{values=[];selectedValue=void 0;constructor(t){this.values=t,this.selectedValue=t[0];}init(){this.container=document.createElement("ul"),this.container.id="github-history-radio";}mount(t){this.init(),this.render(),t.appendChild(this.container);}render(){this.container.innerHTML=this.values.reduce((t,s)=>t+` +
  • ${s}
  • + `,"");}onClick(t){let s=document.getElementById(this.container.id);s.addEventListener("click",i=>{this.values.includes(i.target.innerHTML)&&(Array.from(s.getElementsByTagName("li")).forEach(n=>{n.className="";}),this.selectedValue=i.target.innerHTML,i.target.className="selected",t&&t(this.selectedValue)),i.preventDefault();},!1);}change(t){this.selectedValue=t,this.render();}};var l=class{radio=new d(["All","Issue","PR","Code","Discussions"]);data=[];keyword="";constructor(t){this.fetchData=t,this.init;}init(){this.modal=document.createElement("div"),this.modal.id="github-history-modal",this.modal.className="hide",this.modal.innerHTML=` +
    +
    + +
    +
      + +
    + +
    +
    + `;}mount(){this.init(),document.body.append(this.modal),this.radio.mount(document.getElementById("github-history-footer")),document.getElementById("github-history-modal-mask").addEventListener("click",()=>this.toggle()),document.getElementById("github-history-search").addEventListener("input",t=>{this.keyword=t.target.value,this.render();}),document.getElementById("github-history-result").addEventListener("click",()=>this.toggle()),this.radio.onClick(()=>this.render());}render(){let t=document.getElementById("github-history-result");t||(this.mount(),t=document.getElementById("github-history-result"));let s=h(this.data,{type:this.radio.selectedValue,keyword:this.keyword}),i=document.getElementById("github-history-footer");document.getElementById("github-history-search").focus(),t.innerHTML=s.reduce((n,r)=>n+`
  • + + ${r.title} +
  • `,""),i.childNodes[1].innerHTML=` + Search ${this.keyword&&`'${this.keyword}'`} + Results: + ${s.length} + `;}toggle(){document.getElementById("github-history-modal")||this.mount(),this.modal.className.indexOf("hide")>-1?this.fetchData().then(t=>{this.data=t,this.modal.className="show",this.render();}):(this.clear(),this.modal.className="hide");}contains(t){return this.modal.contains(t)}visible(){return this.modal.className.indexOf("show")>-1}clear(){this.keyword="",document.getElementById("github-history-search").value="",this.radio.change("All");}};var a=class{style=document.createElement("style");constructor(){this.style.textContent=` + @import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap'); + `;}mount(){document.head.appendChild(this.style);}};var m=()=>new Promise(e=>{chrome.runtime.sendMessage({type:"history-query"},t=>{console.log(t),e(t);});}),o=new l(m),g=new a,y=()=>{chrome.runtime.onMessage.addListener(function(e,t,s){console.log(e),e.type=="history-modal"&&o.toggle();});};document.addEventListener("keydown",e=>{e.code==="Escape"&&o.visible()&&o.toggle();});document.addEventListener("click",e=>{o.visible()&&!o.contains(e.target)&&o.toggle();});y();g.mount();o.mount(); diff --git a/package.json b/package.json index bbafb87..968665e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "build": "tsup --config ./tsup.config.ts", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "precommit": "npm run build && git add ." }, "repository": { "type": "git",