home

my firefox custom homepage
Log | Files | Refs | README | git clone https://git.ne02ptzero.me/git/home

commit 882c18665ed8e93ab0c6d23d2d86b57f1e5931de
parent 7e672309e2350fb224082e944e1c2cb6cee23d6f
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue,  3 Oct 2017 18:15:32 +0200

[CORE] ADD: Now can add shortcuts

Diffstat:
Mmain.js | 27++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/main.js b/main.js @@ -41,6 +41,27 @@ var bangs = { } }; +var shortcuts = { + "gh": "https://github.com", + "github": "https://github.com", + "hn": "https://news.ycombinator.com/", + "fb": "https://www.facebook.com/?_rdr", + "facebook": "https://www.facebook.com/?_rdr", + "tw": "https://twitter.com", + "twitter": "https://twitter.com", + "ds": "https://discordapp.com/channels/@me", + "discord": "https://discordapp.com/channels/@me", + "lwn": "https://lwn.net/", + "kbn": "https://korben.info/", + "korben": "https://korben.info/", + "sc": "https://soundcloud.com/stream", + "yt": "https://www.youtube.com/", + "youtube": "https://www.youtube.com/", + "yts": "https://www.youtube.com/feed/subscriptions", + "re": "https://www.reddit.com/", + "reddit": "https://www.reddit.com/" +}; + function submit() { url = document.getElementById('search').value if (url.startsWith("http")) @@ -48,12 +69,16 @@ function submit() { else { res = url.split(" ") - if (bangs[res[0]]) + if (bangs[res[0]] && res.length > 1) { term = url.substring(res[0].length + 1, url.len) url = bangs[res[0]].url.replace(/%s/i, term) window.location.href = url } + else if (shortcuts[url]) + { + window.location.href = shortcuts[url] + } else { window.location.href = "https://www.google.com/search?q=" + url;