Migrate from jshint to eslint
This commit is contained in:
parent
7f9bd58f2c
commit
f047497398
|
@ -0,0 +1,55 @@
|
||||||
|
module.exports = {
|
||||||
|
extends: "airbnb",
|
||||||
|
globals: {
|
||||||
|
Omnibar: false,
|
||||||
|
Front: false,
|
||||||
|
runtime: false,
|
||||||
|
chrome: false,
|
||||||
|
tabOpenLink: false,
|
||||||
|
Hints: false,
|
||||||
|
unmap: false,
|
||||||
|
map: false,
|
||||||
|
mapkey: false,
|
||||||
|
settings: false,
|
||||||
|
removeSearchAliasX: false,
|
||||||
|
addSearchAliasX: false,
|
||||||
|
completions: false,
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
node: true,
|
||||||
|
jquery: true,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
semi: ["error", "never"],
|
||||||
|
"comma-dangle": ["warn", "always-multiline"],
|
||||||
|
quotes: ["warn", "double"],
|
||||||
|
|
||||||
|
"newline-per-chained-call": "off",
|
||||||
|
|
||||||
|
"key-spacing": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
singleLine: {
|
||||||
|
beforeColon: false,
|
||||||
|
afterColon: true,
|
||||||
|
},
|
||||||
|
multiLine: {
|
||||||
|
beforeColon: false,
|
||||||
|
afterColon: true,
|
||||||
|
align: "value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
indent: [
|
||||||
|
"warn",
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
SwitchCase: 0,
|
||||||
|
VariableDeclarator: { var: 2, let: 2, const: 3 },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
1524
completions.js
1524
completions.js
File diff suppressed because it is too large
Load Diff
474
conf.js
474
conf.js
|
@ -1,38 +1,40 @@
|
||||||
//---- Cleanup ----//
|
// ---- Cleanup ----//
|
||||||
// Unmap undesired defaults
|
// Unmap undesired defaults
|
||||||
var unmaps = [ "sb" , "sw", "ob"
|
const unmaps = [
|
||||||
, "ow" , "cp", ";cp"
|
"sb", "sw", "ob",
|
||||||
, ";ap", "spa", "spb"
|
"ow", "cp", ";cp",
|
||||||
, "spd", "sps", "spc"
|
";ap", "spa", "spb",
|
||||||
, "spi", "sfr", "zQ"
|
"spd", "sps", "spc",
|
||||||
, "zz" , "zR", "ab"
|
"spi", "sfr", "zQ",
|
||||||
, "Q" , "q", "ag"
|
"zz", "zR", "ab",
|
||||||
, "af" , ";s", "yp"
|
"Q", "q", "ag",
|
||||||
];
|
"af", ";s", "yp",
|
||||||
|
]
|
||||||
|
|
||||||
unmaps.forEach(function(u) {
|
unmaps.forEach((u) => {
|
||||||
unmap(u);
|
unmap(u)
|
||||||
});
|
})
|
||||||
|
|
||||||
var rmSearchAliases =
|
const rmSearchAliases =
|
||||||
{ "s" : [ "g", "d", "b"
|
{
|
||||||
, "w", "s", "h" ]
|
s: ["g", "d", "b",
|
||||||
};
|
"w", "s", "h"],
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(rmSearchAliases).forEach(function(k) {
|
Object.keys(rmSearchAliases).forEach((k) => {
|
||||||
rmSearchAliases[k].forEach(function(v) {
|
rmSearchAliases[k].forEach((v) => {
|
||||||
removeSearchAliasX(v, k);
|
removeSearchAliasX(v, k)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
//---- Settings ----//
|
// ---- Settings ----//
|
||||||
settings.hintAlign = "left";
|
settings.hintAlign = "left"
|
||||||
settings.omnibarSuggestionTimeout = 500;
|
settings.omnibarSuggestionTimeout = 500
|
||||||
settings.hintGroups = true;
|
settings.hintGroups = true
|
||||||
// settings.hintGroupStart = "middle";
|
// settings.hintGroupStart = "middle";
|
||||||
settings.richHintsForKeystroke = 1;
|
settings.richHintsForKeystroke = 1
|
||||||
|
|
||||||
//---- Theme ----//
|
// ---- Theme ----//
|
||||||
settings.theme = `
|
settings.theme = `
|
||||||
/* Disable RichHints CSS animation */
|
/* Disable RichHints CSS animation */
|
||||||
.expandRichHints {
|
.expandRichHints {
|
||||||
|
@ -41,235 +43,265 @@ settings.theme = `
|
||||||
.collapseRichHints {
|
.collapseRichHints {
|
||||||
animation: 0s ease-in-out 1 forwards collapseRichHints;
|
animation: 0s ease-in-out 1 forwards collapseRichHints;
|
||||||
}
|
}
|
||||||
`;
|
`
|
||||||
|
|
||||||
//---- Maps ----//
|
// ---- Site-Specific Settings ----//
|
||||||
|
if (/github\.com/.test(window.location.hostname)) {
|
||||||
|
settings.theme += `
|
||||||
|
sk_theme {
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.sk_theme tbody {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.sk_theme input {
|
||||||
|
color: #d9dce0;
|
||||||
|
}
|
||||||
|
.sk_theme .url {
|
||||||
|
color: #2173c5;
|
||||||
|
}
|
||||||
|
.sk_theme .annotation {
|
||||||
|
color: #38f;
|
||||||
|
}
|
||||||
|
.sk_theme .omnibar_highlight {
|
||||||
|
color: #fbd60a;
|
||||||
|
}
|
||||||
|
.sk_theme ul>li:nth-child(odd) {
|
||||||
|
background: #1e211d;
|
||||||
|
}
|
||||||
|
.sk_theme ul>li.focused {
|
||||||
|
background: #4ec10d;
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Maps ----//
|
||||||
// Left-hand aliases
|
// Left-hand aliases
|
||||||
// Movement
|
// Movement
|
||||||
map('w', 'k');
|
map("w", "k")
|
||||||
map('s', 'j');
|
map("s", "j")
|
||||||
|
|
||||||
// Right-hand aliases
|
// Right-hand aliases
|
||||||
// Tab Navigation
|
// Tab Navigation
|
||||||
map('J', 'E');
|
map("J", "E")
|
||||||
map('K', 'R');
|
map("K", "R")
|
||||||
|
|
||||||
// History
|
// History
|
||||||
map('H', 'S');
|
map("H", "S")
|
||||||
map('L', 'D');
|
map("L", "D")
|
||||||
|
|
||||||
//---- Mapkeys ----//
|
// ---- Functions ----//
|
||||||
const ri = { repeatIgnore: true };
|
function fakeSpot() {
|
||||||
|
const url = `http://fakespot.com/analyze?url=${window.location.href}`
|
||||||
mapkey('=w', "Lookup whois information for domain", whois, ri);
|
window.open(url, "_blank").focus()
|
||||||
mapkey('=d', "Lookup dns information for domain", dns, ri);
|
|
||||||
mapkey('=D', "Lookup all information for domain", dnsVerbose, ri);
|
|
||||||
mapkey(';se', "#11Edit Settings", editSettings, ri);
|
|
||||||
mapkey(';pd', "Toggle PDF viewer from SurfingKeys", togglePdfViewer, ri);
|
|
||||||
mapkey('gi', "Edit current URL with vim editor", vimEditURL, ri);
|
|
||||||
mapkey('yp', "Copy URL path of current page", () => copyURLPath(), ri);
|
|
||||||
|
|
||||||
const siteleader = "<Space>";
|
|
||||||
|
|
||||||
function mapsitekey(domainRegex, key, desc, f, opts) {
|
|
||||||
opts = opts || {};
|
|
||||||
mapkey(`${siteleader}${key}`, desc, f, Object.assign({}, opts, { domain: domainRegex }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapsitekeys(domain, maps) {
|
function ytFullscreen() {
|
||||||
domain = domain.replace('.', '\\.');
|
$(".ytp-fullscreen-button.ytp-button").click()
|
||||||
var domainRegex = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${domain})(/.*)?`);
|
}
|
||||||
maps.forEach(function(map) {
|
|
||||||
mapsitekey(domainRegex, map[0], map[1], map[2]);
|
function vimeoFullscreen() {
|
||||||
});
|
$(".fullscreen-icon").click()
|
||||||
|
}
|
||||||
|
|
||||||
|
function ghStar(toggle) {
|
||||||
|
const repo = window.location.pathname.slice(1).split("/").slice(0, 2).join("/")
|
||||||
|
const cur = $("div.starring-container > form").filter(function filter() {
|
||||||
|
return $(this).css("display") === "block"
|
||||||
|
})
|
||||||
|
|
||||||
|
let star = "★"
|
||||||
|
let status = "starred"
|
||||||
|
let verb = "is"
|
||||||
|
|
||||||
|
const starred = $(cur).attr("class").indexOf("unstarred") === -1
|
||||||
|
if (starred && toggle) {
|
||||||
|
status = `un${status}`
|
||||||
|
star = "☆"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toggle) {
|
||||||
|
$(cur).find("button").click()
|
||||||
|
verb = "has been"
|
||||||
|
}
|
||||||
|
|
||||||
|
Front.showBanner(`${star} Repository ${repo} ${verb} ${status}!`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function glToggleStar() {
|
||||||
|
const repo = window.location.pathname.slice(1).split("/").slice(0, 2).join("/")
|
||||||
|
const action = `${$(".btn.star-btn > span").click().text().toLowerCase()}red`
|
||||||
|
let star = "☆"
|
||||||
|
if (action === "starred") {
|
||||||
|
star = "★"
|
||||||
|
}
|
||||||
|
Front.showBanner(`${star} Repository ${repo} ${action}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function vimEditURL() {
|
||||||
|
Front.showEditor(window.location.href, (data) => {
|
||||||
|
window.location.href = data
|
||||||
|
}, "url")
|
||||||
|
}
|
||||||
|
|
||||||
|
function whois() {
|
||||||
|
const url = `http://centralops.net/co/DomainDossier.aspx?dom_whois=true&addr=${window.location.hostname}`
|
||||||
|
window.open(url, "_blank").focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
function dns() {
|
||||||
|
const url = `http://centralops.net/co/DomainDossier.aspx?dom_dns=true&addr=${window.location.hostname}`
|
||||||
|
window.open(url, "_blank").focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
function dnsVerbose() {
|
||||||
|
const url = `http://centralops.net/co/DomainDossier.aspx?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=${window.location.hostname}`
|
||||||
|
window.open(url, "_blank").focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
function togglePdfViewer() {
|
||||||
|
chrome.storage.local.get("noPdfViewer", (resp) => {
|
||||||
|
if (!resp.noPdfViewer) {
|
||||||
|
chrome.storage.local.set({ noPdfViewer: 1 }, () => {
|
||||||
|
Front.showBanner("PDF viewer disabled.")
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
chrome.storage.local.remove("noPdfViewer", () => {
|
||||||
|
Front.showBanner("PDF viewer enabled.")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getURLPath(count, domain) {
|
||||||
|
let path = window.location.pathname.slice(1)
|
||||||
|
if (count) {
|
||||||
|
path = path.split("/").slice(0, count).join("/")
|
||||||
|
}
|
||||||
|
if (domain) {
|
||||||
|
path = `${window.location.hostname}/${path}`
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyURLPath(count, domain) {
|
||||||
|
Front.writeClipboard(getURLPath(count, domain))
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewGodoc() {
|
||||||
|
const repo = getURLPath(2, true)
|
||||||
|
tabOpenLink(`https://godoc.org/${repo}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function editSettings() {
|
||||||
|
tabOpenLink("/pages/options.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
function redditCollapseComment() {
|
||||||
|
Hints.create("a.expand", Hints.dispatchMouseClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
function hnCollapseComment() {
|
||||||
|
Hints.create("a.togg", Hints.dispatchMouseClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
function redditVote() {
|
||||||
|
Hints.create("div.arrow", Hints.dispatchMouseClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
function hnVote() {
|
||||||
|
Hints.create("div.votearrow", Hints.dispatchMouseClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
function twitterFollowUser() {
|
||||||
|
Hints.create(".follow-button", Hints.dispatchMouseClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Mapkeys ----//
|
||||||
|
const ri = { repeatIgnore: true }
|
||||||
|
|
||||||
|
mapkey("=w", "Lookup whois information for domain", whois, ri)
|
||||||
|
mapkey("=d", "Lookup dns information for domain", dns, ri)
|
||||||
|
mapkey("=D", "Lookup all information for domain", dnsVerbose, ri)
|
||||||
|
mapkey(";se", "#11Edit Settings", editSettings, ri)
|
||||||
|
mapkey(";pd", "Toggle PDF viewer from SurfingKeys", togglePdfViewer, ri)
|
||||||
|
mapkey("gi", "Edit current URL with vim editor", vimEditURL, ri)
|
||||||
|
mapkey("yp", "Copy URL path of current page", () => copyURLPath(), ri)
|
||||||
|
|
||||||
|
const siteleader = "<Space>"
|
||||||
|
|
||||||
|
function mapsitekey(domainRegex, key, desc, f, o) {
|
||||||
|
const opts = o || {}
|
||||||
|
mapkey(`${siteleader}${key}`, desc, f, Object.assign({}, opts, { domain: domainRegex }))
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapsitekeys(d, maps) {
|
||||||
|
const domain = d.replace(".", "\\.")
|
||||||
|
const domainRegex = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${domain})(/.*)?`)
|
||||||
|
maps.forEach((map) => {
|
||||||
|
mapsitekey(domainRegex, map[0], map[1], map[2])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
mapsitekeys("amazon.com", [
|
mapsitekeys("amazon.com", [
|
||||||
['fs', "Fakespot", fakeSpot],
|
["fs", "Fakespot", fakeSpot],
|
||||||
// TODO: Add to cart
|
// TODO: Add to cart
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("yelp.com", [
|
mapsitekeys("yelp.com", [
|
||||||
['fs', "Fakespot", fakeSpot],
|
["fs", "Fakespot", fakeSpot],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("youtube.com", [
|
mapsitekeys("youtube.com", [
|
||||||
['F', "Toggle fullscreen", ytFullscreen],
|
["F", "Toggle fullscreen", ytFullscreen],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("vimeo.com", [
|
mapsitekeys("vimeo.com", [
|
||||||
['F', "Toggle fullscreen", vimeoFullscreen],
|
["F", "Toggle fullscreen", vimeoFullscreen],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("github.com", [
|
mapsitekeys("github.com", [
|
||||||
['s', "Toggle Star", () => ghStar(true)],
|
["s", "Toggle Star", () => ghStar(true)],
|
||||||
['S', "Check Star", () => ghStar(false)],
|
["S", "Check Star", () => ghStar(false)],
|
||||||
['y', "Copy Project Path", () => copyURLPath(2)],
|
["y", "Copy Project Path", () => copyURLPath(2)],
|
||||||
['Y', "Copy Project Path (including domain)", () => copyURLPath(2, true)],
|
["Y", "Copy Project Path (including domain)", () => copyURLPath(2, true)],
|
||||||
['D', "View GoDoc for Project", viewGodoc],
|
["D", "View GoDoc for Project", viewGodoc],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("gitlab.com", [
|
mapsitekeys("gitlab.com", [
|
||||||
['s', "Toggle Star", glToggleStar],
|
["s", "Toggle Star", glToggleStar],
|
||||||
['y', "Copy Project Path", () => copyURLPath(2)],
|
["y", "Copy Project Path", () => copyURLPath(2)],
|
||||||
['Y', "Copy Project Path (including domain)", () => copyURLPath(2, true)],
|
["Y", "Copy Project Path (including domain)", () => copyURLPath(2, true)],
|
||||||
['D', "View GoDoc for Project", viewGodoc],
|
["D", "View GoDoc for Project", viewGodoc],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("twitter.com", [
|
mapsitekeys("twitter.com", [
|
||||||
['f', "Follow user", twitterFollowUser],
|
["f", "Follow user", twitterFollowUser],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("reddit.com", [
|
mapsitekeys("reddit.com", [
|
||||||
['c', "Collapse comment", redditCollapseComment],
|
["c", "Collapse comment", redditCollapseComment],
|
||||||
['v', "Cast vote", redditVote],
|
["v", "Cast vote", redditVote],
|
||||||
]);
|
])
|
||||||
|
|
||||||
mapsitekeys("news.ycombinator.com", [
|
mapsitekeys("news.ycombinator.com", [
|
||||||
['c', "Collapse comment", hnCollapseComment],
|
["c", "Collapse comment", hnCollapseComment],
|
||||||
['v', "Cast vote", hnVote],
|
["v", "Cast vote", hnVote],
|
||||||
]);
|
])
|
||||||
|
|
||||||
//---- Search & completion ----//
|
// ---- Search & completion ----//
|
||||||
// Search leader
|
// Search leader
|
||||||
const sl = 'a';
|
const sl = "a"
|
||||||
|
|
||||||
// Register Search Engine Completions
|
// Register Search Engine Completions
|
||||||
// The `completions` variable is defined in `completions.js` and
|
// The `completions` variable is defined in `completions.js` and
|
||||||
// is prepended to this file by gulp-concat.
|
// is prepended to this file by gulp-concat.
|
||||||
Object.keys(completions).map(function(k) {
|
Object.keys(completions).forEach((k) => {
|
||||||
var s = completions[k], // Search Engine object
|
const s = completions[k] // Search Engine object
|
||||||
la = sl + s.alias; // Search leader + alias
|
const la = sl + s.alias // Search leader + alias
|
||||||
|
|
||||||
addSearchAliasX(s.alias, s.name, s.search, sl, s.compl, s.callback);
|
addSearchAliasX(s.alias, s.name, s.search, sl, s.compl, s.callback)
|
||||||
mapkey(la, '#8Search ' + s.name, 'Front.openOmnibar({type: "SearchEngine", extra: "' + s.alias + '"})');
|
mapkey(la, `#8Search ${s.name}`, `Front.openOmnibar({type: "SearchEngine", extra: "${s.alias}"})`)
|
||||||
});
|
})
|
||||||
|
|
||||||
//---- Functions ----//
|
|
||||||
function fakeSpot() {
|
|
||||||
var url = "http://fakespot.com/analyze?url=" + window.location.href;
|
|
||||||
window.open(url, '_blank').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ytFullscreen() {
|
|
||||||
$('.ytp-fullscreen-button.ytp-button').click();
|
|
||||||
}
|
|
||||||
|
|
||||||
function vimeoFullscreen() {
|
|
||||||
$('.fullscreen-icon').click();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ghStar(toggle) {
|
|
||||||
var repo = window.location.pathname.slice(1).split("/").slice(0,2).join("/");
|
|
||||||
var cur = $('div.starring-container > form').filter(function() {
|
|
||||||
return $(this).css("display") === "block";
|
|
||||||
});
|
|
||||||
|
|
||||||
var star = "★";
|
|
||||||
var status = "starred";
|
|
||||||
var verb = "is";
|
|
||||||
|
|
||||||
var starred = $(cur).attr("class").indexOf("unstarred") === -1;
|
|
||||||
if (starred && toggle) {
|
|
||||||
status = "un" + status;
|
|
||||||
star = "☆";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toggle) {
|
|
||||||
$(cur).find("button").click();
|
|
||||||
verb = "has been";
|
|
||||||
}
|
|
||||||
|
|
||||||
Front.showBanner(`${star} Repository ${repo} ${verb} ${status}!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function glToggleStar() {
|
|
||||||
var repo = window.location.pathname.slice(1).split("/").slice(0,2).join("/");
|
|
||||||
var action = $('.btn.star-btn > span').click().text().toLowerCase() + "red";
|
|
||||||
var star = "☆";
|
|
||||||
if (action === "starred") {
|
|
||||||
star = "★";
|
|
||||||
}
|
|
||||||
Front.showBanner(star + " Repository " + repo + " " + action);
|
|
||||||
}
|
|
||||||
|
|
||||||
function vimEditURL() {
|
|
||||||
Front.showEditor(window.location.href, function(data) {
|
|
||||||
window.location.href = data;
|
|
||||||
}, 'url');
|
|
||||||
}
|
|
||||||
|
|
||||||
function whois() {
|
|
||||||
var url = "http://centralops.net/co/DomainDossier.aspx?dom_whois=true&addr=" + window.location.hostname;
|
|
||||||
window.open(url, '_blank').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function dns() {
|
|
||||||
var url = "http://centralops.net/co/DomainDossier.aspx?dom_dns=true&addr=" + window.location.hostname;
|
|
||||||
window.open(url, '_blank').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function dnsVerbose() {
|
|
||||||
var url = "http://centralops.net/co/DomainDossier.aspx?dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true&addr=" + window.location.hostname;
|
|
||||||
window.open(url, '_blank').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function togglePdfViewer() {
|
|
||||||
chrome.storage.local.get("noPdfViewer", function(resp) {
|
|
||||||
if(!resp.noPdfViewer) {
|
|
||||||
chrome.storage.local.set({"noPdfViewer": 1}, function() {
|
|
||||||
Front.showBanner("PDF viewer disabled.");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
chrome.storage.local.remove("noPdfViewer", function() {
|
|
||||||
Front.showBanner("PDF viewer enabled.");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getURLPath(count, domain) {
|
|
||||||
var path = window.location.pathname.slice(1);
|
|
||||||
if (count) {
|
|
||||||
path = path.split('/').slice(0, count).join('/');
|
|
||||||
}
|
|
||||||
if (domain) {
|
|
||||||
path = window.location.hostname + '/' + path;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyURLPath(count, domain) {
|
|
||||||
Front.writeClipboard(getURLPath(count, domain));
|
|
||||||
}
|
|
||||||
|
|
||||||
function viewGodoc() {
|
|
||||||
var repo = getURLPath(2, true);
|
|
||||||
tabOpenLink("https://godoc.org/" + repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
function editSettings() {
|
|
||||||
tabOpenLink("/pages/options.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
function redditCollapseComment() {
|
|
||||||
Hints.create('a.expand', Hints.dispatchMouseClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hnCollapseComment() {
|
|
||||||
Hints.create('a.togg', Hints.dispatchMouseClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function redditVote() {
|
|
||||||
Hints.create('div.arrow', Hints.dispatchMouseClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hnVote() {
|
|
||||||
Hints.create('div.votearrow', Hints.dispatchMouseClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function twitterFollowUser() {
|
|
||||||
Hints.create('.follow-button', Hints.dispatchMouseClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: set ft=javascript expandtab:
|
// vim: set ft=javascript expandtab:
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-disable no-unused-vars, camelcase */
|
||||||
|
|
||||||
// This is a reference for how conf.priv.js should look.
|
// This is a reference for how conf.priv.js should look.
|
||||||
//
|
//
|
||||||
// Copy this file to a new file named "conf.priv.js" and update
|
// Copy this file to a new file named "conf.priv.js" and update
|
||||||
|
@ -10,26 +12,26 @@
|
||||||
|
|
||||||
// These are private API keys which are required for certain search completions.
|
// These are private API keys which are required for certain search completions.
|
||||||
// You can obtain them all for free at the supplied links.
|
// You can obtain them all for free at the supplied links.
|
||||||
var keys = {
|
const keys = {
|
||||||
crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
|
crunchbase: "", // https://about.crunchbase.com/crunchbase-basic-access/
|
||||||
google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
|
google_cs: "", // https://developers.google.com/custom-search/json-api/v1/overview?hl=en_US
|
||||||
google_yt: "", // https://developers.google.com/youtube/v3/docs/
|
google_yt: "", // https://developers.google.com/youtube/v3/docs/
|
||||||
wolframalpha: "", // https://products.wolframalpha.com/api/
|
wolframalpha: "", // https://products.wolframalpha.com/api/
|
||||||
domainr: "", // https://market.mashape.com/domainr/domainr
|
domainr: "", // https://market.mashape.com/domainr/domainr
|
||||||
|
|
||||||
//*** Google Custom Search Engines ***//
|
//* ** Google Custom Search Engines ***//
|
||||||
// Can be created at https://cse.google.com/cse
|
// Can be created at https://cse.google.com/cse
|
||||||
// Simply create a separate Custom Search Engine for each of the following entries,
|
// Simply create a separate Custom Search Engine for each of the following entries,
|
||||||
// pasting the provided URL string in the "Sites to Search" field.
|
// pasting the provided URL string in the "Sites to Search" field.
|
||||||
// Then, after creation, go to the control panel for the new Search Engine and copy the
|
// Then, after creation, go to the control panel for the new Search Engine and copy the
|
||||||
// Search Engine ID (cx) into the appropriate configuration variable below:
|
// Search Engine ID (cx) into the appropriate configuration variable below:
|
||||||
google_cx_ex: "", // hexdocs.pm/*/master/*.html
|
google_cx_ex: "", // hexdocs.pm/*/master/*.html
|
||||||
google_cx_af: "", // bbs.archlinux.org/*
|
google_cx_af: "", // bbs.archlinux.org/*
|
||||||
google_cx_al: "", // www.archlinux.org/packages/*/x86_64/*
|
google_cx_al: "", // www.archlinux.org/packages/*/x86_64/*
|
||||||
google_cx_no: "", // nodejs.org/api/*
|
google_cx_no: "", // nodejs.org/api/*
|
||||||
google_cx_cs: "", // chrome.google.com/webstore/*
|
google_cx_cs: "", // chrome.google.com/webstore/*
|
||||||
google_cx_jq: "", // api.jquery.com/*
|
google_cx_jq: "", // api.jquery.com/*
|
||||||
};
|
}
|
||||||
|
|
||||||
// You can place any additional private/sensitive variables here and they will
|
// You can place any additional private/sensitive variables here and they will
|
||||||
// be included before the rest of your configuration scripts.
|
// be included before the rest of your configuration scripts.
|
||||||
|
|
180
gulpfile.js
180
gulpfile.js
|
@ -1,22 +1,22 @@
|
||||||
const gulp = require('gulp');
|
const gulp = require("gulp")
|
||||||
const concat = require('gulp-concat');
|
const concat = require("gulp-concat")
|
||||||
const replace = require('gulp-replace');
|
const replace = require("gulp-replace")
|
||||||
const rename = require('gulp-rename');
|
const rename = require("gulp-rename")
|
||||||
const jshint = require('gulp-jshint');
|
const eslint = require("gulp-eslint")
|
||||||
const path = require('path');
|
const path = require("path")
|
||||||
const del = require('del');
|
const del = require("del")
|
||||||
const os = require('os');
|
const os = require("os")
|
||||||
const fs = require('fs');
|
const fs = require("fs")
|
||||||
const spawn = require('child_process').spawn;
|
const { spawn } = require("child_process")
|
||||||
const { URL } = require('url');
|
const { URL } = require("url")
|
||||||
const compl = require('./completions');
|
const compl = require("./completions")
|
||||||
|
|
||||||
var paths = {
|
const paths = {
|
||||||
scripts: ['conf.priv.js', 'completions.js', 'conf.js'],
|
scripts: ["conf.priv.js", "completions.js", "conf.js"],
|
||||||
gulpfile: ['gulpfile.js'],
|
gulpfile: ["gulpfile.js"],
|
||||||
readme: ['README.tmpl.md'],
|
readme: ["README.tmpl.md"],
|
||||||
screenshots: 'assets/screenshots',
|
screenshots: "assets/screenshots",
|
||||||
};
|
}
|
||||||
|
|
||||||
// This notice will be injected into the generated README.md file
|
// This notice will be injected into the generated README.md file
|
||||||
const disclaimer = `\
|
const disclaimer = `\
|
||||||
|
@ -26,92 +26,86 @@ NOTICE:
|
||||||
This is an automatically generated file - Do not edit it directly.
|
This is an automatically generated file - Do not edit it directly.
|
||||||
The source file is README.tmpl.md
|
The source file is README.tmpl.md
|
||||||
|
|
||||||
-->`;
|
-->`
|
||||||
|
|
||||||
gulp.task('gulp-autoreload', function() {
|
gulp.task("gulp-autoreload", () => {
|
||||||
var p;
|
let p
|
||||||
var spawnChildren = function() {
|
const spawnChildren = function spawnChildren() {
|
||||||
if (p) p.kill();
|
if (p) p.kill()
|
||||||
p = spawn('gulp', ['lint-gulpfile', 'install', 'watch-nogulpfile'], {stdio: 'inherit'});
|
p = spawn("gulp", ["lint-gulpfile", "install", "watch-nogulpfile"], { stdio: "inherit" })
|
||||||
};
|
}
|
||||||
gulp.watch('gulpfile.js', spawnChildren);
|
gulp.watch("gulpfile.js", spawnChildren)
|
||||||
spawnChildren();
|
spawnChildren()
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('clean', function() {
|
gulp.task("clean", () => del(["build"]))
|
||||||
return del(['build']);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('lint', function() {
|
gulp.task("lint", () =>
|
||||||
return gulp.src([].concat(paths.scripts, paths.gulpfile))
|
gulp
|
||||||
.pipe(jshint())
|
.src([].concat(paths.scripts, paths.gulpfile))
|
||||||
.pipe(jshint.reporter('jshint-stylish'));
|
.pipe(eslint())
|
||||||
});
|
.pipe(eslint.format()))
|
||||||
|
|
||||||
gulp.task('lint-gulpfile', function() {
|
gulp.task("lint", () =>
|
||||||
return gulp.src([].concat(paths.gulpfile))
|
gulp
|
||||||
.pipe(jshint())
|
.src(paths.gulpfile)
|
||||||
.pipe(jshint.reporter('jshint-stylish'));
|
.pipe(eslint())
|
||||||
});
|
.pipe(eslint.format()))
|
||||||
|
|
||||||
gulp.task('build', ['clean', 'lint', 'readme'], function() {
|
gulp.task("build", ["clean", "lint", "readme"], () => gulp.src(paths.scripts)
|
||||||
return gulp.src(paths.scripts)
|
.pipe(concat(".surfingkeys"))
|
||||||
.pipe(concat('.surfingkeys'))
|
.pipe(gulp.dest("build")))
|
||||||
.pipe(gulp.dest('build'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('install', ['build'], function() {
|
gulp.task("install", ["build"], () => gulp.src("build/.surfingkeys")
|
||||||
return gulp.src('build/.surfingkeys')
|
.pipe(gulp.dest(os.homedir())))
|
||||||
.pipe(gulp.dest(os.homedir()));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('watch', function() {
|
gulp.task("watch", () => {
|
||||||
gulp.watch([].concat(paths.scripts, paths.gulpfile), ['readme', 'install']);
|
gulp.watch([].concat(paths.scripts, paths.gulpfile), ["readme", "install"])
|
||||||
gulp.watch(paths.readme, ['readme']);
|
gulp.watch(paths.readme, ["readme"])
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('watch-nogulpfile', function() {
|
gulp.task("watch-nogulpfile", () => {
|
||||||
gulp.watch([].concat(paths.scripts), ['readme', 'install']);
|
gulp.watch([].concat(paths.scripts), ["readme", "install"])
|
||||||
gulp.watch(paths.readme, ['readme']);
|
gulp.watch(paths.readme, ["readme"])
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('readme', function() {
|
gulp.task("readme", () => {
|
||||||
var screens = {};
|
const screens = {}
|
||||||
var screenshotList = "";
|
let screenshotList = ""
|
||||||
fs.readdirSync(path.join(__dirname, paths.screenshots)).forEach(function(s) {
|
fs.readdirSync(path.join(__dirname, paths.screenshots)).forEach((s) => {
|
||||||
var file = path.basename(s, '.png').split('-');
|
const file = path.basename(s, ".png").split("-")
|
||||||
var alias = file[0];
|
const alias = file[0]
|
||||||
if (!screens[alias]) {
|
if (!screens[alias]) {
|
||||||
screens[alias] = [];
|
screens[alias] = []
|
||||||
}
|
}
|
||||||
screens[alias].push(path.join(paths.screenshots, path.basename(s)));
|
screens[alias].push(path.join(paths.screenshots, path.basename(s)))
|
||||||
});
|
})
|
||||||
var table = Object.keys(compl).sort(function(a, b) {
|
const table = Object.keys(compl).sort((a, b) => {
|
||||||
if (a < b) return -1;
|
if (a < b) return -1
|
||||||
if (a > b) return 1;
|
if (a > b) return 1
|
||||||
return 0;
|
return 0
|
||||||
}).reduce(function(a, k) {
|
}).reduce((a, k) => {
|
||||||
var c = compl[k];
|
const c = compl[k]
|
||||||
var u = new URL(c.search);
|
const u = new URL(c.search)
|
||||||
var domain = (u.hostname === "cse.google.com") ? "Google Custom Search" : u.hostname;
|
const domain = (u.hostname === "cse.google.com") ? "Google Custom Search" : u.hostname
|
||||||
var s = "";
|
let s = ""
|
||||||
if (screens[c.alias]) {
|
if (screens[c.alias]) {
|
||||||
screens[c.alias].forEach(function(url, i) {
|
screens[c.alias].forEach((url, i) => {
|
||||||
var num = (i > 0) ? ` ${i+1}` : "";
|
const num = (i > 0) ? ` ${i + 1}` : ""
|
||||||
s += `[\\[${i+1}\\]](#${c.name}${num.replace(' ', '-')}) `;
|
s += `[\\[${i + 1}\\]](#${c.name}${num.replace(" ", "-")}) `
|
||||||
screenshotList += `##### ${c.name}${num}\n`;
|
screenshotList += `##### ${c.name}${num}\n`
|
||||||
screenshotList += `![${c.name} screenshot](./${url})\n\n`;
|
screenshotList += `![${c.name} screenshot](./${url})\n\n`
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return a + `| \`${c.alias}\` | \`${c.name}\` | \`${domain}\` | ${s} |\n`;
|
return `${a}| \`${c.alias}\` | \`${c.name}\` | \`${domain}\` | ${s} |\n`
|
||||||
}, "");
|
}, "")
|
||||||
return gulp.src(['./README.tmpl.md'])
|
return gulp.src(["./README.tmpl.md"])
|
||||||
.pipe(replace("<!--DISCLAIMER-->", disclaimer))
|
.pipe(replace("<!--DISCLAIMER-->", disclaimer))
|
||||||
.pipe(replace("<!--COMPL_COUNT-->", Object.keys(compl).length))
|
.pipe(replace("<!--COMPL_COUNT-->", Object.keys(compl).length))
|
||||||
.pipe(replace("<!--COMPL_TABLE-->", table))
|
.pipe(replace("<!--COMPL_TABLE-->", table))
|
||||||
.pipe(replace("<!--SCREENSHOTS-->", screenshotList))
|
.pipe(replace("<!--SCREENSHOTS-->", screenshotList))
|
||||||
.pipe(rename('README.md'))
|
.pipe(rename("README.md"))
|
||||||
.pipe(gulp.dest('.'));
|
.pipe(gulp.dest("."))
|
||||||
});
|
})
|
||||||
|
|
||||||
gulp.task('default', ['build']);
|
gulp.task("default", ["build"])
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,12 +19,11 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"del": "^3.0.0",
|
"del": "^3.0.0",
|
||||||
|
"eslint": "^4.12.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-jshint": "^2.0.4",
|
"gulp-eslint": "^4.0.0",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-rename": "^1.2.2",
|
||||||
"gulp-replace": "^0.6.1",
|
"gulp-replace": "^0.6.1"
|
||||||
"jshint": "^2.9.5",
|
|
||||||
"jshint-stylish": "^2.2.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue