forked from KorySchneider/tab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1 lines (1 loc) · 16.1 KB
/
index.html
1
<!DOCTYPE html><html><head><title>tab</title><meta charset="utf-8"><link rel="icon" type="image/png" href="img/favicon.png"></head><body><div id="app"><div id="clock"></div><input id="input" autofocus="" autocomplete="off" spellcheck="false" autocapitalize="none" autocorrect="off"><div id="message"></div></div><script>!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n(1),function(){var e={defaultCommand:"dg",bgColor:"#1a1b26",textColor:"#f7768e",fontSize:"1.75em",clockSize:"2em",showClock:!1,militaryClock:!1,alwaysNewTab:!1,gistID:"",links:[],caretColor:"auto"},t=Object.assign({},e),n={ddg:"dg","?":"help"},o=!1,r="",i=null;function a(){var t=document.querySelector("#input").value.trim();if(document.querySelector("#input").value="",document.querySelector("#message").innerHTML="",""!==t){r=t;for(var i=t.split("/"),a=i[0].toLowerCase(),s=0;s<i.length;s++)i[s]=i[s].trim();for(var l=Object.keys(v),u=Object.keys(n),f=!1,h=0;h<l.length;h++){if(a===l[h]){f=!0,i.shift();break}if(a===u[h]){f=!0,a=n[a],i.shift();break}}var m=!1;p(i[0])&&(m=!0,a=i.shift());var g=!1;if(!m&&!f)for(var k=0;k<e.links.length;k++)if(e.links[k].command==a){g=!0,a=i.shift();break}if("n"===i[i.length-1]&&(o=!0,i.pop()),m)c(d(a));else if(f)v[a](i);else if(g){var y=b(a);0==i.length?c(y.url):c(y.url+y.search+i.join(" "))}else v[e.defaultCommand](i);return!1}}function c(t){return o||e.alwaysNewTab?window.open(t,"_blank").focus():window.location.href=t,o=!1,!1}function s(){if(Storage){if(null===localStorage.getItem("taabSettings"))localStorage.setItem("taabSettings",JSON.stringify(t));else{var n=JSON.parse(localStorage.getItem("taabSettings"));e=Object.assign(e,n)}null!==localStorage.getItem("customCommands")&&((o=JSON.parse(localStorage.getItem("customCommands")))&&(e.links=o,u()),localStorage.removeItem("customCommands"))}var o}function l(){document.body.style.backgroundColor=e.bgColor,document.body.style.color=e.textColor,document.body.style.fontSize=e.fontSize,document.body.style.caretColor=e.caretColor;var t=document.querySelector("#clock");t.style.fontSize=e.clockSize,e.showClock?t.style.display="inline":t.style.display="none"}function u(){localStorage.setItem("taabSettings",JSON.stringify(e))}function f(e,t){var n=document.querySelector("#message");i&&(n.innerHTML="",clearTimeout(i)),n.innerHTML=e,i=setTimeout((function(){n.innerHTML=""}),t)}function d(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=/(http(s)?:\/\/.)/.test(e)?e:"http://"+e;return o+t+encodeURIComponent(n)}function h(){var t=new Date,n=t.getHours();!e.militaryClock&&n>12&&(n-=12);var o=n.toString(),r=("0"+t.getMinutes()).slice(-2);document.querySelector("#clock").innerText=o+":"+r,setTimeout(h,1e3)}function m(e){var t=e.which||e.keyCode;if(13===t)a();else if(38===t&&""!==r){var n=document.querySelector("#input");n.focus(),n.value=r,setTimeout((function(){n.setSelectionRange(n.value.length,n.value.length)}),2)}}function g(t,n){var o=void 0;try{o=JSON.parse(t)}catch(e){return f("Error parsing config, see console for details",5e3),void console.log(e)}for(var r in o)e[r]=o[r];e.gistID=n,u(),l(),f("Config imported",5e3)}function p(e){return!(!/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(e)||e.includes(" "))}function b(t){for(var n=0;n<e.links.length;n++)if(t==e.links[n].command)return e.links[n];return null}window.onload=function(){s(),l(),u(),document.querySelector("#input").focus(),document.querySelector("body").addEventListener("click",(function(){document.querySelector("#input").focus()})),document.onkeydown=m,h()};var v={set:function(n){var o=function(e){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(e)};switch(n[0]){case"defaultCommand":if(1===n.length){f("Default command: "+e.defaultCommand,5e3);break}Object.keys(v).includes(n[1])?(e.defaultCommand=n[1],f("Set default command to "+n[1],3e3)):f("Error: command "+n[1]+" not found; default command not changed",1e4);break;case"bgColor":if(1===n.length){f("Current background color: "+e.bgColor,8e3);break}o(n[1])?e.bgColor=n[1]:f("Error: invalid hex value",5e3);break;case"textColor":if(1===n.length){f("Current background color: "+e.textColor,8e3);break}o(n[1])?e.textColor=n[1]:f("Error: invalid hex value",5e3);break;case"caretColor":if(1===n.length){f("Current caret color: "+e.caretColor,8e3);break}n[1]&&(e.caretColor=n[1]);break;case"fontSize":if(1===n.length){f("Current input font size: "+e.fontSize,8e3);break}n[1]&&(e.fontSize=n[1]);break;case"clockSize":if(1===n.length){f("Current clock font size: "+e.clockSize,8e3);break}n[1]&&(e.clockSize=n[1]);break;case"newtab":case"alwaysNewTab":if(1===n.length){f("alwaysNewTab is "+(e.alwaysNewTab?"on":"off"),5e3);break}"on"===n[1]?e.alwaysNewTab=!0:"off"===n[1]?e.alwaysNewTab=!1:f("Must be set to either 'on' or 'off'",5e3);break;case"clock":if(1===n.length){f("Clock is "+(e.showClock?"on":"off")+",\n "+(e.militaryClock?"24":"12")+"-hour",5e3);break}switch(n[1]){case"on":e.showClock=!0;break;case"off":e.showClock=!1;break;case"12":e.militaryClock=!1;break;case"24":e.militaryClock=!0;break;default:f("Must be set to 'on', 'off', '12' or '24'",5e3)}break;case"defaults":localStorage.removeItem("taabSettings"),e=t,s(),l(),u(),f("Settings reset to defaults",5e3);break;default:f('"'+n[0]+'" is not a valid setting',5e3)}u(),l()},link:function(t){switch(t.length){case 0:f('link is a builtin command<br>To search for "link" try dg/link<br>',8e3);break;case 1:if("show"===t[0]){for(var o="",r=0;r<e.links.length;r++){var i=e.links[r];o+=i.command+" --\x3e "+i.url,""!==i.search&&(o+=" ("+i.search+")"),o+="<br>"}f(o,3e4);break}var a=b(t[0]);if(a){var c='"'+t[0]+'" links to '+a.url;""!==a.search&&(c+=" ("+a.search+")"),f(c,1e4)}break;case 2:case 3:if("delete"===t[1])for(var s=0;s<e.links.length;s++)t[0]==e.links[s].command&&(e.links.splice(s,1),f("Link "+t[0]+" deleted",5e3));else{for(var l=0;l<e.links.length;l++)if(e.links[l].command==t[0]){if(!confirm("Overwrite existing shortcut?"))return;for(var h=0;h<e.links.length;h++)e.links[h].command==t[0]&&e.links.splice(h,1)}if(Object.keys(v).includes(t[0])||Object.keys(n).includes(t[0]))return void f("Cannot override builtin command: "+t[0],5e3);var m=d(t[1]);if(!p(m))return void f("Invalid URL",5e3);e.links.push({command:t[0],url:m,search:t[2]||""})}}u()},config:function(t){switch(t[0]){case"export":f(localStorage.getItem("taabSettings"),25e3),window.getSelection().selectAllChildren(document.querySelector("#message"));break;case"import":g(t[1]);break;case"open":""!==e.gistID?(o=!0,v.gist([e.gistID])):f("Error: No gist ID found. Make sure you have fetched your config at least once.",8e3);break;case"fetch":var n=void 0;if(t.length>1)try{n=t[1].match(/([0-9A-Za-z]{32})/)[0]}catch(e){return void f("Error: unable to parse gist ID.<br>Try entering just the 32 character ID string.",8e3)}else{if(null==e.gistID){f("Error: no gist ID",5e3);break}n=e.gistID}f("Fetching gist...",2500),function(e){var t=new XMLHttpRequest,n="https://api.github.com/gists/"+e;t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var n=JSON.parse(t.responseText).files;if(n.length>1)return void f("Error: Multiple files found in gist. Please use a gist with only one file.",5e3);g(n[Object.keys(n)[0]].content,e)}},t.open("GET",n,!0),t.send(null)}(n)}},help:function(e){o=!0,c("https://github.com/koryschneider/tab#readme")},g:function(e){var t="https://google.com";0==e.length?c(t):c(d(t,"/search?q=",e))},dg:function(e){var t="https://duckduckgo.com";0==e.length?c(t):c(d(t,"/?q=",e))},r:function(e){var t,n="https://reddit.com",o=e.length>0?e[0]:"",r=function(e){return["hot","new","rising","controversial","top","gilded","wiki","promoted"].includes(e)};switch(e.length){case 0:c(n);break;case 1:c(d(n,"/r/",e[0]));break;case 2:c(n+"/r/"+(o+=r(e[1])?"/"+e[1]:""));break;case 3:["top","controversial"].includes(e[1])?o+=(t=e[2],["day","week","month","year","all"].includes(t)?"/"+e[1]+"?t="+e[2]:""):o+=r(e[1])?"/"+e[1]:"",c(n+"/r/"+o)}},hn:function(e){var t="https://news.ycombinator.com";if(0==e.length)c(t);else switch(e[0]){case"new":c(t+"/newest");break;case"comments":c(t+"/newcomments");break;case"show":c(t+"/show");break;case"ask":c(t+"/ask");break;case"jobs":c(t+"/jobs");break;case"submit":c(t+"/submit")}},yt:function(e){var t="https://youtube.com";if(0==e.length)c(t);else switch(e[0]){case"subs":c(t+"/feed/subscriptions");break;case"hist":c(t+"/feed/history");break;case"save":c(t+"/feed/playlist");break;case"wl":c(t+"/playlist?list=WL");break;default:c(d(t,"/results?search_query=",e[0]))}},w:function(e){var t="https://wikipedia.org";0==e.length?c(t):c(d(t,"/w/index.php?title=Special:Search&search=",e.join(" ")))},gh:function(e){var t="https://github.com";0===e.length?c(t):2===e.length?c(t+"/"+e[0]+"/"+e[1]+"/"):c(t+"/"+e[0]+"/")},gist:function(e){var t="https://gist.github.com";0==e.length?c(t):c(t+"/"+e.join(""))},wolf:function(e){var t="http://wolframalpha.com";0==e.length?c(t):c(d(t,"/input/?i=",e.join(" ")))},n:function(e){var t="https://netflix.com";0==e.length?c(t):c(d(t,"/search?q=",e.join(" ")))},imdb:function(e){var t="http://imdb.com";0==e.length?c(t):c(d(t,"/find?s=all&q=",e.join(" ")))},gmap:function(e){var t="https://google.com/maps";0==e.length?c(t):c(d(t,"/search/",e.join(" ")))},gdrive:function(e){var t="https://drive.google.com";0==e.length?c(t):c(d(t,"/drive/search?q=",e.join(" ")))},gcal:function(e){c("https://calendar.google.com")},gimg:function(e){var t="https://google.com";0==e.length?c(t):c(d(t,"/search?tbm=isch&q=",e.join(" ")))},gmail:function(e){var t="https://mail.google.com";0==e.length?c(t):c(d(t,"/mail/u/0/#search/",e.join(" ")))},gkeep:function(e){var t="https://keep.google.com";0==e.length?c(t):c(d(t,"/#search/text=",e.join(" ")))},dict:function(e){var t="http://dictionary.com";0==e.length?c(t):c(d(t,"/browse/",e.join(" ")))},thes:function(e){var t="http://thesaurus.com";0==e.length?c(t):c(d(t,"/browse/",e.join(" ")))},tokped:function(e){var t="https://tokopedia.com";if(0==e.length)c(t);else switch(e[0]){case"wish":c(t+"/wishlist");break;case"cart":c(t+"/cart");break;case"chat":c(t+"/chat");break;case"order":c(t+"/order-list");break;default:c(d(t,"/search?q=",e[0]))}},qmk:function(e){if(0==e.length)c("https://github.com/qmk/qmk_firmware");else switch(e[0]){case"wiki":c("https://docs.qmk.fm/");break;case"conf":c("https://config.qmk.fm/#/crkbd/rev1/LAYOUT_split_3x6_3")}},dpl:function(e){var t="https://www.deepl.com/en/translator";0===e.length?c(t):1===e.length?c(t+"#"+e[0]+"/"):(e.length,c(t+"#"+e[0]+"/"+e[1]+"/"))},x:function(e){var t="https://x.com";0==e.length?c(t):c(d(t,"/search?q=",e.join(" ")))},idlix:function(e){var t="https://tv3.idlix.asia";0==e.length?c(t):c(d(t,"/search/",e.join(" ")))},gpt:function(e){c("https://chatgpt.com")},bb:function(e){c("https://blackbox.ai")},pmail:function(e){c("https://mail.proton.me/u/0/inbox")},pcal:function(e){c("https://calendar.proton.me")},pass:function(e){c("https://pass.proton.me")},pdrive:function(e){c("https://drive.proton.me")},tw:function(e){c("https://www.twitch.tv/")}}}()},function(e,t,n){var o=n(2),r=n(3);"string"==typeof(r=r.__esModule?r.default:r)&&(r=[[e.i,r,""]]);var i={insert:"head",singleton:!1},a=(o(r,i),r.locals?r.locals:{});e.exports=a},function(e,t,n){"use strict";var o,r=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),a=[];function c(e){for(var t=-1,n=0;n<a.length;n++)if(a[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},o=[],r=0;r<e.length;r++){var i=e[r],s=t.base?i[0]+t.base:i[0],l=n[s]||0,u="".concat(s," ").concat(l);n[s]=l+1;var f=c(u),d={css:i[1],media:i[2],sourceMap:i[3]};-1!==f?(a[f].references++,a[f].updater(d)):a.push({identifier:u,updater:p(d,t),references:1}),o.push(u)}return o}function l(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var r=n.nc;r&&(o.nonce=r)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var a=i(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var u,f=(u=[],function(e,t){return u[e]=t,u.filter(Boolean).join("\n")});function d(e,t,n,o){var r=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(e.styleSheet)e.styleSheet.cssText=f(t,r);else{var i=document.createTextNode(r),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(i,a[t]):e.appendChild(i)}}function h(e,t,n){var o=n.css,r=n.media,i=n.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),i&&btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var m=null,g=0;function p(e,t){var n,o,r;if(t.singleton){var i=g++;n=m||(m=l(t)),o=d.bind(null,n,i,!1),r=d.bind(null,n,i,!0)}else n=l(t),o=h.bind(null,n,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var o=0;o<n.length;o++){var r=c(n[o]);a[r].references--}for(var i=s(e,t),l=0;l<n.length;l++){var u=c(n[l]);0===a[u].references&&(a[u].updater(),a.splice(u,1))}n=i}}}},function(e,t,n){(t=n(4)(!1)).push([e.i,'html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n width: 100%;\n font-size: 1.75em;\n}\nbody, #app {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n}\n#clock {\n font-size: 2em;\n font-weight: bold;\n margin-top: -20vh;\n margin-bottom: 10%;\n display: none;\n}\n#input {\n text-align: center;\n font-size: inherit;\n color: inherit;\n background: transparent;\n border: none;\n outline: none;\n width: 95%;\n}\n#message {\n font-size: 0.5em;\n margin-top: 42px;\n text-align: center;\n}\n#clock,\n#input,\n#message {\n font-family: "Helvetica Neue", Roboto, sans-serif;\n}\n',""]),e.exports=t},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var r=(a=o,c=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(c),"/*# ".concat(s," */")),i=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[n].concat(i).concat([r]).join("\n")}var a,c,s;return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,o){"string"==typeof e&&(e=[[null,e,""]]);var r={};if(o)for(var i=0;i<this.length;i++){var a=this[i][0];null!=a&&(r[a]=!0)}for(var c=0;c<e.length;c++){var s=[].concat(e[c]);o&&r[s[0]]||(n&&(s[2]?s[2]="".concat(n," and ").concat(s[2]):s[2]=n),t.push(s))}},t}}]);</script></body></html>