From: alorimer Date: Sun, 9 Jul 2017 01:44:13 +0000 (+1000) Subject: Initial commit X-Git-Url: https://git.lorimer.id.au/newtab.git/diff_plain/cc353593b6ca02e19d6dcc543cd0236b5fdd5565 Initial commit --- diff --git a/README.md b/README.md index b2b0072..cf62fe4 100644 --- a/README.md +++ b/README.md @@ -1 +1,30 @@ -# newtab \ No newline at end of file +NOTE: This is the original README from Start Clean New Tab Page Lite. + All I did was add in the display of website favicons and all new tabs forced + open in a new tab upon left click. + +Original git repo: https://github.com/startclean/Chrome-Extension + +# Start Clean New Tab Page Lite + +Start Clean Light is a version of the extension with no search. +Start Clean offers a minimal ui that replaces Google Chrome's default page. It includes the top sites you visit, and can show your apps. You can add your own custom links and drag to reorder. + + * Version 0.2.7 bundles code and fonts locally for offline usage. + * Version 0.2.6 offers a background color changer in the options. Thank you to koopa1338 on github! + * Version 0.2.5 includes bug fixes. + * Version 0.2.4 changes the way search works with autocomplete powered by duckduckgo and wikipedia. + * Version 0.2.2 offers an option to choose search box location and search engine & urls in the search box resolve. + +[Donate to dev](https://www.paypal.me/rawas) + +![](http://i.imgur.com/PnM9k1S.png) + +![](http://i.imgur.com/bHBfXLk.png) + +![](http://i.imgur.com/mIm30O8.png) + +Start Clean New Tab Page has less features and options than alternatives such as Awesome New Tab Page, but it is cleaner, faster, and has only what you need. + +Use Start Clean with your linux desktop to spice it up even more! + +![](http://i.imgur.com/UV9KV8N.jpg) diff --git a/Sortable.min.js b/Sortable.min.js new file mode 100644 index 0000000..e95d2a3 --- /dev/null +++ b/Sortable.min.js @@ -0,0 +1,2 @@ +/*! Sortable 1.4.2 - MIT | git://github.com/rubaxa/Sortable.git */ +!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():"undefined"!=typeof Package?Sortable=a():window.Sortable=a()}(function(){"use strict";function a(a,b){if(!a||!a.nodeType||1!==a.nodeType)throw"Sortable: `el` must be HTMLElement, and not "+{}.toString.call(a);this.el=a,this.options=b=r({},b),a[L]=this;var c={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(a.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1};for(var d in c)!(d in b)&&(b[d]=c[d]);V(b);for(var f in this)"_"===f.charAt(0)&&(this[f]=this[f].bind(this));this.nativeDraggable=b.forceFallback?!1:P,e(a,"mousedown",this._onTapStart),e(a,"touchstart",this._onTapStart),this.nativeDraggable&&(e(a,"dragover",this),e(a,"dragenter",this)),T.push(this._onDragOver),b.store&&this.sort(b.store.get(this))}function b(a){v&&v.state!==a&&(h(v,"display",a?"none":""),!a&&v.state&&w.insertBefore(v,s),v.state=a)}function c(a,b,c){if(a){c=c||N,b=b.split(".");var d=b.shift().toUpperCase(),e=new RegExp("\\s("+b.join("|")+")(?=\\s)","g");do if(">*"===d&&a.parentNode===c||(""===d||a.nodeName.toUpperCase()==d)&&(!b.length||((" "+a.className+" ").match(e)||[]).length==b.length))return a;while(a!==c&&(a=a.parentNode))}return null}function d(a){a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.preventDefault()}function e(a,b,c){a.addEventListener(b,c,!1)}function f(a,b,c){a.removeEventListener(b,c,!1)}function g(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(K," ").replace(" "+b+" "," ");a.className=(d+(c?" "+b:"")).replace(K," ")}}function h(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return N.defaultView&&N.defaultView.getComputedStyle?c=N.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function i(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;f>e;e++)c(d[e],e);return d}return[]}function j(a,b,c,d,e,f,g){var h=N.createEvent("Event"),i=(a||b[L]).options,j="on"+c.charAt(0).toUpperCase()+c.substr(1);h.initEvent(c,!0,!0),h.to=b,h.from=e||b,h.item=d||b,h.clone=v,h.oldIndex=f,h.newIndex=g,b.dispatchEvent(h),i[j]&&i[j].call(a,h)}function k(a,b,c,d,e,f){var g,h,i=a[L],j=i.options.onMove;return g=N.createEvent("Event"),g.initEvent("move",!0,!0),g.to=b,g.from=a,g.dragged=c,g.draggedRect=d,g.related=e||b,g.relatedRect=f||b.getBoundingClientRect(),a.dispatchEvent(g),j&&(h=j.call(i,g)),h}function l(a){a.draggable=!1}function m(){R=!1}function n(a,b){var c=a.lastElementChild,d=c.getBoundingClientRect();return(b.clientY-(d.top+d.height)>5||b.clientX-(d.right+d.width)>5)&&c}function o(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function p(a){var b=0;if(!a||!a.parentNode)return-1;for(;a&&(a=a.previousElementSibling);)"TEMPLATE"!==a.nodeName.toUpperCase()&&b++;return b}function q(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}function r(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}var s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J={},K=/\s+/g,L="Sortable"+(new Date).getTime(),M=window,N=M.document,O=M.parseInt,P=!!("draggable"in N.createElement("div")),Q=function(a){return a=N.createElement("x"),a.style.cssText="pointer-events:auto","auto"===a.style.pointerEvents}(),R=!1,S=Math.abs,T=([].slice,[]),U=q(function(a,b,c){if(c&&b.scroll){var d,e,f,g,h=b.scrollSensitivity,i=b.scrollSpeed,j=a.clientX,k=a.clientY,l=window.innerWidth,m=window.innerHeight;if(z!==c&&(y=b.scroll,z=c,y===!0)){y=c;do if(y.offsetWidth=l-j)-(h>=j),g=(h>=m-k)-(h>=k),(f||g)&&(d=M)),(J.vx!==f||J.vy!==g||J.el!==d)&&(J.el=d,J.vx=f,J.vy=g,clearInterval(J.pid),d&&(J.pid=setInterval(function(){d===M?M.scrollTo(M.pageXOffset+f*i,M.pageYOffset+g*i):(g&&(d.scrollTop+=g*i),f&&(d.scrollLeft+=f*i))},24)))}},30),V=function(a){var b=a.group;b&&"object"==typeof b||(b=a.group={name:b}),["pull","put"].forEach(function(a){a in b||(b[a]=!0)}),a.groups=" "+b.name+(b.put.join?" "+b.put.join(" "):"")+" "};return a.prototype={constructor:a,_onTapStart:function(a){var b=this,d=this.el,e=this.options,f=a.type,g=a.touches&&a.touches[0],h=(g||a).target,i=h,k=e.filter;if(!("mousedown"===f&&0!==a.button||e.disabled)&&(h=c(h,e.draggable,d))){if(D=p(h),"function"==typeof k){if(k.call(this,a,h,this))return j(b,i,"filter",h,d,D),void a.preventDefault()}else if(k&&(k=k.split(",").some(function(a){return a=c(i,a.trim(),d),a?(j(b,a,"filter",h,d,D),!0):void 0})))return void a.preventDefault();(!e.handle||c(i,e.handle,d))&&this._prepareDragStart(a,g,h)}},_prepareDragStart:function(a,b,c){var d,f=this,h=f.el,j=f.options,k=h.ownerDocument;c&&!s&&c.parentNode===h&&(G=a,w=h,s=c,t=s.parentNode,x=s.nextSibling,F=j.group,d=function(){f._disableDelayedDrag(),s.draggable=!0,g(s,f.options.chosenClass,!0),f._triggerDragStart(b)},j.ignore.split(",").forEach(function(a){i(s,a.trim(),l)}),e(k,"mouseup",f._onDrop),e(k,"touchend",f._onDrop),e(k,"touchcancel",f._onDrop),j.delay?(e(k,"mouseup",f._disableDelayedDrag),e(k,"touchend",f._disableDelayedDrag),e(k,"touchcancel",f._disableDelayedDrag),e(k,"mousemove",f._disableDelayedDrag),e(k,"touchmove",f._disableDelayedDrag),f._dragStartTimer=setTimeout(d,j.delay)):d())},_disableDelayedDrag:function(){var a=this.el.ownerDocument;clearTimeout(this._dragStartTimer),f(a,"mouseup",this._disableDelayedDrag),f(a,"touchend",this._disableDelayedDrag),f(a,"touchcancel",this._disableDelayedDrag),f(a,"mousemove",this._disableDelayedDrag),f(a,"touchmove",this._disableDelayedDrag)},_triggerDragStart:function(a){a?(G={target:s,clientX:a.clientX,clientY:a.clientY},this._onDragStart(G,"touch")):this.nativeDraggable?(e(s,"dragend",this),e(w,"dragstart",this._onDragStart)):this._onDragStart(G,!0);try{N.selection?N.selection.empty():window.getSelection().removeAllRanges()}catch(b){}},_dragStarted:function(){w&&s&&(g(s,this.options.ghostClass,!0),a.active=this,j(this,w,"start",s,w,D))},_emulateDragOver:function(){if(H){if(this._lastX===H.clientX&&this._lastY===H.clientY)return;this._lastX=H.clientX,this._lastY=H.clientY,Q||h(u,"display","none");var a=N.elementFromPoint(H.clientX,H.clientY),b=a,c=" "+this.options.group.name,d=T.length;if(b)do{if(b[L]&&b[L].options.groups.indexOf(c)>-1){for(;d--;)T[d]({clientX:H.clientX,clientY:H.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode);Q||h(u,"display","")}},_onTouchMove:function(b){if(G){a.active||this._dragStarted(),this._appendGhost();var c=b.touches?b.touches[0]:b,d=c.clientX-G.clientX,e=c.clientY-G.clientY,f=b.touches?"translate3d("+d+"px,"+e+"px,0)":"translate("+d+"px,"+e+"px)";I=!0,H=c,h(u,"webkitTransform",f),h(u,"mozTransform",f),h(u,"msTransform",f),h(u,"transform",f),b.preventDefault()}},_appendGhost:function(){if(!u){var a,b=s.getBoundingClientRect(),c=h(s),d=this.options;u=s.cloneNode(!0),g(u,d.ghostClass,!1),g(u,d.fallbackClass,!0),h(u,"top",b.top-O(c.marginTop,10)),h(u,"left",b.left-O(c.marginLeft,10)),h(u,"width",b.width),h(u,"height",b.height),h(u,"opacity","0.8"),h(u,"position","fixed"),h(u,"zIndex","100000"),h(u,"pointerEvents","none"),d.fallbackOnBody&&N.body.appendChild(u)||w.appendChild(u),a=u.getBoundingClientRect(),h(u,"width",2*b.width-a.width),h(u,"height",2*b.height-a.height)}},_onDragStart:function(a,b){var c=a.dataTransfer,d=this.options;this._offUpEvents(),"clone"==F.pull&&(v=s.cloneNode(!0),h(v,"display","none"),w.insertBefore(v,s)),b?("touch"===b?(e(N,"touchmove",this._onTouchMove),e(N,"touchend",this._onDrop),e(N,"touchcancel",this._onDrop)):(e(N,"mousemove",this._onTouchMove),e(N,"mouseup",this._onDrop)),this._loopId=setInterval(this._emulateDragOver,50)):(c&&(c.effectAllowed="move",d.setData&&d.setData.call(this,c,s)),e(N,"drop",this),setTimeout(this._dragStarted,0))},_onDragOver:function(a){var d,e,f,g=this.el,i=this.options,j=i.group,l=j.put,o=F===j,p=i.sort;if(void 0!==a.preventDefault&&(a.preventDefault(),!i.dragoverBubble&&a.stopPropagation()),I=!0,F&&!i.disabled&&(o?p||(f=!w.contains(s)):F.pull&&l&&(F.name===j.name||l.indexOf&&~l.indexOf(F.name)))&&(void 0===a.rootEl||a.rootEl===this.el)){if(U(a,i,this.el),R)return;if(d=c(a.target,i.draggable,g),e=s.getBoundingClientRect(),f)return b(!0),void(v||x?w.insertBefore(s,v||x):p||w.appendChild(s));if(0===g.children.length||g.children[0]===u||g===a.target&&(d=n(g,a))){if(d){if(d.animated)return;r=d.getBoundingClientRect()}b(o),k(w,g,s,e,d,r)!==!1&&(s.contains(g)||(g.appendChild(s),t=g),this._animate(e,s),d&&this._animate(r,d))}else if(d&&!d.animated&&d!==s&&void 0!==d.parentNode[L]){A!==d&&(A=d,B=h(d),C=h(d.parentNode));var q,r=d.getBoundingClientRect(),y=r.right-r.left,z=r.bottom-r.top,D=/left|right|inline/.test(B.cssFloat+B.display)||"flex"==C.display&&0===C["flex-direction"].indexOf("row"),E=d.offsetWidth>s.offsetWidth,G=d.offsetHeight>s.offsetHeight,H=(D?(a.clientX-r.left)/y:(a.clientY-r.top)/z)>.5,J=d.nextElementSibling,K=k(w,g,s,e,d,r);if(K!==!1){if(R=!0,setTimeout(m,30),b(o),1===K||-1===K)q=1===K;else if(D){var M=s.offsetTop,N=d.offsetTop;q=M===N?d.previousElementSibling===s&&!E||H&&E:N>M}else q=J!==s&&!G||H&&G;s.contains(g)||(q&&!J?g.appendChild(s):d.parentNode.insertBefore(s,q?J:d)),t=s.parentNode,this._animate(e,s),this._animate(r,d)}}}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();h(b,"transition","none"),h(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)"),b.offsetWidth,h(b,"transition","all "+c+"ms"),h(b,"transform","translate3d(0,0,0)"),clearTimeout(b.animated),b.animated=setTimeout(function(){h(b,"transition",""),h(b,"transform",""),b.animated=!1},c)}},_offUpEvents:function(){var a=this.el.ownerDocument;f(N,"touchmove",this._onTouchMove),f(a,"mouseup",this._onDrop),f(a,"touchend",this._onDrop),f(a,"touchcancel",this._onDrop)},_onDrop:function(b){var c=this.el,d=this.options;clearInterval(this._loopId),clearInterval(J.pid),clearTimeout(this._dragStartTimer),f(N,"mousemove",this._onTouchMove),this.nativeDraggable&&(f(N,"drop",this),f(c,"dragstart",this._onDragStart)),this._offUpEvents(),b&&(I&&(b.preventDefault(),!d.dropBubble&&b.stopPropagation()),u&&u.parentNode.removeChild(u),s&&(this.nativeDraggable&&f(s,"dragend",this),l(s),g(s,this.options.ghostClass,!1),g(s,this.options.chosenClass,!1),w!==t?(E=p(s),E>=0&&(j(null,t,"sort",s,w,D,E),j(this,w,"sort",s,w,D,E),j(null,t,"add",s,w,D,E),j(this,w,"remove",s,w,D,E))):(v&&v.parentNode.removeChild(v),s.nextSibling!==x&&(E=p(s),E>=0&&(j(this,w,"update",s,w,D,E),j(this,w,"sort",s,w,D,E)))),a.active&&((null===E||-1===E)&&(E=D),j(this,w,"end",s,w,D,E),this.save())),w=s=t=u=x=v=y=z=G=H=I=E=A=B=F=a.active=null)},handleEvent:function(a){var b=a.type;"dragover"===b||"dragenter"===b?s&&(this._onDragOver(a),d(a)):("drop"===b||"dragend"===b)&&this._onDrop(a)},toArray:function(){for(var a,b=[],d=this.el.children,e=0,f=d.length,g=this.options;f>e;e++)a=d[e],c(a,g.draggable,this.el)&&b.push(a.getAttribute(g.dataIdAttr)||o(a));return b},sort:function(a){var b={},d=this.el;this.toArray().forEach(function(a,e){var f=d.children[e];c(f,this.options.draggable,d)&&(b[a]=f)},this),a.forEach(function(a){b[a]&&(d.removeChild(b[a]),d.appendChild(b[a]))})},save:function(){var a=this.options.store;a&&a.set(this)},closest:function(a,b){return c(a,b||this.options.draggable,this.el)},option:function(a,b){var c=this.options;return void 0===b?c[a]:(c[a]=b,void("group"===a&&V(c)))},destroy:function(){var a=this.el;a[L]=null,f(a,"mousedown",this._onTapStart),f(a,"touchstart",this._onTapStart),this.nativeDraggable&&(f(a,"dragover",this),f(a,"dragenter",this)),Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")}),T.splice(T.indexOf(this._onDragOver),1),this._onDrop(),this.el=a=null}},a.utils={on:e,off:f,css:h,find:i,is:function(a,b){return!!c(a,b,a)},extend:r,throttle:q,closest:c,toggleClass:g,index:p},a.create=function(b,c){return new a(b,c)},a.version="1.4.2",a}); \ No newline at end of file diff --git a/admin.js b/admin.js new file mode 100644 index 0000000..17fbdbd --- /dev/null +++ b/admin.js @@ -0,0 +1,156 @@ +var mainlist; + +//chrome.tabs.create({ url: chrome.extension.getURL("newtab.html") }); +//window.close(); + +document.addEventListener("DOMContentLoaded", function() { + chrome.storage.sync.get( +{"lists": [ + [ + ["syncthing", "https://localhost:8384/"], + ["todoist", "http://todoist.com/"], + ["github", "https://github.com/"], + ["gmail", "http://mail.google.com/"], + ["drive", "http://drive.google.com/"] + ], + [ + ["unixporn", "http://reddit.com/r/unixporn"], + ["news", "http://reddit.com/r/news"], + ["funny", "http://reddit.com/r/funny"], + ["linux", "http://reddit.com/r/linux"], + ["all", "http://reddit.com/r/all"] + ], + [ + ["elementary", "https://elementary.io/"], + ["ubuntu", "https://www.ubuntu.com/"], + ["fedora", "https://getfedora.org/"], + ["mint", "https://linuxmint.com/"], + ["arch", "https://www.archlinux.org/"] + ] +], +"l1name": "productivity", +"l2name": "general", +"l3name": "distros"}, + userListsCallback); +}); + +function listToArray(list) { + var l = []; + var elem = list.getElementsByTagName("li"); + for (var i = 0; i < elem.length; ++i) { + l[i] = [elem[i].getElementsByTagName("a")[0].innerText, elem[i].getElementsByTagName("a")[0].getAttribute("href")]; + } + return l; +} + +var userListsCallback = function(lists) { + mainlist = [lists["l1name"],lists["l2name"],lists["l3name"]] + for(var i=0;i+"); + + var list = lists["lists"][i]; + for(var j=0;j +extractDomain(siteurl,1)+ "+name+""); + // ronmurphy end + //li.insertAdjacentHTML("beforeend", ""+name+""); + li.insertAdjacentHTML("beforeend", "-"); + ul.appendChild(li); + } + + var sortable = Sortable.create(ul, { + group: "userlists", + onUpdate: function (evt) { + save(); + } + }); + } + + menu(); + +}; + +function listen(li) { + li.addEventListener('click', function(event){ + var r = event.target.id.split("-"); + if (r[0] == "delete") { + var el = document.getElementById(r[2]+"-"+r[1]); + el.outerHTML = ""; + delete el; + save(); + } else { + var ul = document.getElementById(r[1]); + ul.insertAdjacentHTML("beforeend", "
s
"); + var inp = document.getElementById("div-"+listToArray(ul).length.toString()); + var span = document.getElementById("input-"+listToArray(ul).length.toString()); + var form = document.getElementById("form-"+listToArray(ul).length.toString()); + + form.addEventListener('keyup', function(event){ + if (event.keyCode == 13) { + span.click(); + } + }); + + span.addEventListener('click', function(event){ + inp.outerHTML = ""; + delete inp; + + if (inp.getElementsByClassName("name")[0].value != "" || inp.getElementsByClassName("url")[0].value != "") { + var li = document.createElement("li"); + li.setAttribute("id",r[1]+"-"+listToArray(ul).length.toString()); + //var splitted = splitHostname(inp.getElementsByClassName("url")[0].value); fix later + var siteurl = addhttp(inp.getElementsByClassName("url")[0].value); + var name = inp.getElementsByClassName("name")[0].value; + + li.insertAdjacentHTML("beforeend", ""+name+""); + li.insertAdjacentHTML("beforeend", "-"); + document.getElementById(r[1]).appendChild(li); + save(); + listen(li); + } + }); + } + }, false); +} + +function menu() { + var allUserLi = document.querySelectorAll('.users-list > ul > li > span, .users-list > ul > .title > span'); + + allUserLi.forEach(function(li, p_index){ + listen(li); + }); +} + +function save(l) { + var set = l || JSON.parse(JSON.stringify(mainlist)); + d = [] + d = set; + for (var i = 0; i < set.length; ++i) { + e = document.getElementById(set[i]); + d[i] = listToArray(e); + } + chrome.storage.sync.set( {"lists": d} ); +} diff --git a/apps.js b/apps.js new file mode 100644 index 0000000..b5bf212 --- /dev/null +++ b/apps.js @@ -0,0 +1,55 @@ +document.addEventListener("DOMContentLoaded", function() { + chrome.management.getAll(getAllCallback); + }); + + var getAllCallback = function(list) { + chrome.storage.sync.get({ + "showApps": true + }, function(items) { + if (items["showApps"] == true) { + var apps = document.getElementById("apps"); + + function isEnabledApp(x) { + return x.isApp; + } + list = list.filter(isEnabledApp); + for(var i=0;i + + + New Tab + + + + + + + + + + + + + +
+ + + + diff --git a/options.html b/options.html new file mode 100644 index 0000000..2100b20 --- /dev/null +++ b/options.html @@ -0,0 +1,39 @@ + + + + + newtab + + + + + + + + + + + + + + + + + + + + +
1
2
3
bg
+ + + + + + +
alorimer
original
+ + + + + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..44eacbc --- /dev/null +++ b/options.js @@ -0,0 +1,36 @@ +function save_options() { + var l1name = document.getElementById('l1').value; + var l2name = document.getElementById('l2').value; + var l3name = document.getElementById('l3').value; + + var bgvalue = document.getElementById('bg').value; + console.log(bgvalue); + + chrome.storage.sync.set({ + "l1name": l1name, + "l2name": l2name, + "l3name": l3name, + "bgvalue": bgvalue, + }, function() { + window.close(); + + }); +} + + +function restore_options() { + chrome.storage.sync.get({ + "l1name": "list1", + "l2name": "list2", + "l3name": "list3", + "bgvalue": "#222222"}, + function(items) { + document.getElementById('l1').value = items["l1name"]; + document.getElementById('l2').value = items["l2name"]; + document.getElementById('l3').value = items["l3name"]; + document.getElementById('bg').value = items["bgvalue"]; + }); +} + +document.addEventListener('DOMContentLoaded', restore_options); +document.getElementById('save').addEventListener('click', save_options); diff --git a/roboto-v15-latin-700.woff b/roboto-v15-latin-700.woff new file mode 100644 index 0000000..bf737c1 Binary files /dev/null and b/roboto-v15-latin-700.woff differ diff --git a/roboto-v15-latin-700.woff2 b/roboto-v15-latin-700.woff2 new file mode 100644 index 0000000..11cde5d Binary files /dev/null and b/roboto-v15-latin-700.woff2 differ diff --git a/roboto-v15-latin-regular.woff b/roboto-v15-latin-regular.woff new file mode 100644 index 0000000..941dfa4 Binary files /dev/null and b/roboto-v15-latin-regular.woff differ diff --git a/roboto-v15-latin-regular.woff2 b/roboto-v15-latin-regular.woff2 new file mode 100644 index 0000000..120796b Binary files /dev/null and b/roboto-v15-latin-regular.woff2 differ diff --git a/roboto.css b/roboto.css new file mode 100644 index 0000000..2c6181d --- /dev/null +++ b/roboto.css @@ -0,0 +1,18 @@ +/* roboto-regular - latin */ +@font-face { + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), + url('./roboto-v15-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ + url('./roboto-v15-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ +} +/* roboto-700 - latin */ +@font-face { + font-family: 'Roboto'; + font-style: normal; + font-weight: 700; + src: local('Roboto Bold'), local('Roboto-Bold'), + url('./roboto-v15-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */ + url('./roboto-v15-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ +} diff --git a/search.js b/search.js new file mode 100644 index 0000000..ef41627 --- /dev/null +++ b/search.js @@ -0,0 +1,111 @@ +document.addEventListener("DOMContentLoaded", function() { + chrome.storage.sync.get({"search": "google", "searchplace": "bottom"}, searchCallback); +}); + +var jsonmain; + +function jsonparse(json) { + jsonmain = json; + searchbox = document.getElementById("search-box"); + if (json.AbstractSource == "Wikipedia") { + document.getElementById("duckduckres").innerHTML = ""; + var script = document.createElement("script"); + script.setAttribute("src", "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles="+json.AbstractURL.split('/')[json.AbstractURL.split('/').length-1]+"&callback=wikicallback"); + //script.setAttribute("src", "https://en.wikipedia.org/w/api.php?format=json&action=query&list=search&prop=extracts&exintro=&explaintext=&callback=wikicallback&srsearch="+searchbox.value); + document.body.appendChild(script); + script.outerHTML = ""; + script.delete; + + if (typeof json.RelatedTopics[0] != "undefined") { + var div = document.createElement('div'); + div.innerHTML = json.RelatedTopics[0].Result; + var a = div.getElementsByTagName("a")[0]; + a.className = "extrares"; + document.getElementById("duckduckres").appendChild(a); + + div.innerHTML = json.RelatedTopics[1].Result; + var a = div.getElementsByTagName("a")[0]; + a.className = "extrares"; + document.getElementById("duckduckres").appendChild(a); + + div.innerHTML = json.RelatedTopics[2].Result; + var a = div.getElementsByTagName("a")[0]; + a.className = "extrares"; + document.getElementById("duckduckres").appendChild(a); + } + } +} + +function wikicallback(json) { + var page = json.query.pages[Object.keys(json.query.pages)[0]]; + //console.log(json.query.pages); + var a = document.createElement('a'); + a.href = "http://en.wikipedia.org/?curid="+page.pageid; + a.innerText = page.title + " - "+page.extract; + if (page.extract != "") { + a.innerText = page.title + " - "+page.extract; + } else { + a.innerText = page.title; + } + a.className = "mainres"; + [].forEach.call(document.querySelectorAll('.mainres'),function(e){ + e.parentNode.removeChild(e); + }); + document.getElementById("wikires").appendChild(a); +} + +var searchCallback = function(list) { + var form; + var searchbox; + + var searchplace = list["searchplace"]; + var formstring = "
\ + \ +
"; + + if (searchplace == "top") { + document.getElementById("search1").className += " active"; + document.getElementById("search1").insertAdjacentHTML("beforeend", formstring); + } else if (searchplace == "middle") { + document.getElementById("search2").className += " active"; + document.getElementById("search2").insertAdjacentHTML("beforeend", formstring); + } else { + document.getElementById("search3").className += " active"; + document.getElementById("search3").insertAdjacentHTML("beforeend", formstring); + } + + form = document.getElementById("search-form"); + searchbox = document.getElementById("search-box"); + + searchbox.onkeyup = function(){ + var val = searchbox.value; + if (val.length > 1) { + var script = document.createElement('script'); + script.src = 'https://api.duckduckgo.com/?q='+searchbox.value+'&format=json&callback=jsonparse'; + document.body.appendChild(script); + script.outerHTML = ""; + script.delete; + } + } + + if (list["search"] == "duckduckgo") { + form.setAttribute("action", "https://duckduckgo.com/?"); + } else if (list["search"] == "yahoo") { + form.setAttribute("action", "https://search.yahoo.com/search?"); + } else if (list["search"] == "bing") { + form.setAttribute("action", "https://www.bing.com/search?"); + } + + form.addEventListener("submit", + function(e){ + var value = searchbox.value; + e.preventDefault(); + var value = searchbox.value; + if (value.indexOf(".") >= 0) { + window.location = addhttp(value);; + } else { + form.submit(); + } + }, false); +} + diff --git a/sites.js b/sites.js new file mode 100644 index 0000000..6c9565c --- /dev/null +++ b/sites.js @@ -0,0 +1,39 @@ +function extractDomain(url, y) { + var domain; + + //remove protocol + if (url.indexOf("://") > -1) { domain = url.split('/')[2]; } + else { domain = url.split('/')[0]; } + + //remove port number + domain = domain.split(':')[0]; + + + if (y == 1) { + d = splitHostname(domain); + if (d.subdomain != "www" && d.subdomain != "") { + return d.subdomain; + } + else { + return d.domain; + } + } else { + return domain; + } +} + +function addhttp(url) { + if (!/^(f|ht)tps?:\/\//i.test(url)) { + url = "http://" + url; + } + return url; +} + +function splitHostname(h) { + var result = {}; + var urlParts = new RegExp('([a-z\-0-9]{2,63})\.([a-z\.]{2,5})$').exec(h); + result.domain = urlParts[1]; + result.type = urlParts[2]; + result.subdomain = h.replace(result.domain + '.' + result.type, '').slice(0, -1);; + return result; +} \ No newline at end of file diff --git a/start.html b/start.html new file mode 100644 index 0000000..ee79d7b --- /dev/null +++ b/start.html @@ -0,0 +1,15 @@ + + + + + New Tab + + + + + + + +redirecting + + diff --git a/start.js b/start.js new file mode 100644 index 0000000..3325be9 --- /dev/null +++ b/start.js @@ -0,0 +1,2 @@ +chrome.tabs.create({ url: chrome.extension.getURL("newtab.html") }); +window.close(); diff --git a/style.css b/style.css new file mode 100644 index 0000000..5fe3349 --- /dev/null +++ b/style.css @@ -0,0 +1,253 @@ +#search-form > input#search-box:-webkit-autofill { + -webkit-box-shadow: 0 0 0 1000px #222 inset !important; + -webkit-text-fill-color: #b5b5a4 !important; +} + +#callback { + bottom: 0; + position: absolute; + height: 115px; + width: 31.1rem; +} + +#search3 { + margin-top: -1.5rem; +} + +#wikires > a { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + margin-bottom: 0.5em; + height: 19px; + display: block; + color: inherit; + text-decoration: none; +} + +#duckduckres > a { + margin-bottom: 0.5em; + display: block; + color: inherit; + text-decoration: none; +} + +#topsites-list { + display: none; +} + +#search1.active { + margin-bottom: 2em; +} + +#search2.active { + margin-top: 2em; +} + +.name { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 120px; +} + +.inp { + width: 200px; +} + +.inp > input { + font-size: 16px !important; +} + +.users-list > ul > li > span { + margin-top: 4px; + font-weight: normal; + color: black; + width: 10px; + padding: 4px 5px 4px 10px; + background: white; + float: right; + display: none; + cursor: pointer; +} + +.users-list > ul > .inp > span { + margin-top: 4px; + font-weight: normal; + color: black; + width: 10px; + padding: 2px 5px 3px 6px; + background: white; + cursor: pointer; +} + +.users-list > ul > li:hover > span { + display: inline-block; +} + +.users-list > ul > .title:hover > span { + display: inline-block; +} + +.users-list > ul { + margin: 0; +} + +.users-list > ul > .title > span { + margin-top: 14px; + font-size: 75% !Important; + font-weight: normal; + color: black; + width: 10px; + content: "+"; + padding: 6px 6px 5px 9px; + background: white; + float: right; + display: none; + cursor: pointer; +} + +.users-list > ul > li > a, .users-list > ul > .title > p { + width: calc(100% - 45px); + display: inline-block; +} + +div#apps { + overflow-x: scroll; + display: flex; + width: 907px; + align-content: flex-start; + justify-content: flex-start; +} + +::-webkit-scrollbar +{ + width: 12px; /* for vertical scrollbars */ + height: 12px; /* for horizontal scrollbars */ +} + +::-webkit-scrollbar-track +{ + background: rgba(0, 0, 0, 0); +} + +::-webkit-scrollbar-thumb +{ + background: rgba(0, 0, 0, 0.2); +} + +li.sortable-chosen.sortable-ghost > a { + background-color: white; + color: #2A313B !important; +} + + +.title > p { + width: 160px; + margin-left: 0.5rem; + margin-bottom: 0.5rem !important; +} +.app { + cursor: pointer; + text-align: center; + margin: 16px; +} + +.app > .image { + width: 64px; + padding: 8px; +} + +html, body { + font-family: Roboto !important; + font-size: 16px !important; + width: 100vw; + height: 100vh; +} + +body { + width: 100%; + height: 100%; + margin: 0; + background-color: #2A313B; + color: #b5b5a4; +} + +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; +} + +.favorites { + display: flex; + flex-direction: row; +} + +.favorites-list { + width: 10rem; + margin: 0.5rem 2em 2em 2em; +} + +ul { + list-style: none; + padding: 0; +} + +.title { + margin-bottom: 0.5rem; + font-weight: bold; + text-align: left; + border-bottom: 1px solid #b5b5a4; +} + +ul > li > a { + color: #b5b5a4; + outline: none; + display: block; + text-decoration: none; + padding: 0.5rem; +} + +ul > li > a:hover { + color: #2A313B; + background-color: #b5b5a4; +} + +.search.active { + width: 30rem; + padding: 0.5rem; + border: 1px solid #b5b5a4; +} + +#search-box { + font-size: inherit; + width: 100%; + margin: auto; + padding: 0; + background-color: rgba(0, 0, 0, 0); + color: #b5b5a4; + border: none; +} + +#search-box:focus { + outline: none; +} + + +/* webkit compat */ + +.container { + display: -webkit-flex; + -webkit-flex-direction: column; + -webkit-align-items: center; + -webkit-justify-content: center; +} + +.favorites { + display: -webkit-flex; + -webkit-flex-direction: row; +}