Last active
March 17, 2022 00:32
-
-
Save neta540/6eb424cf8ac283e44a7e5d7773cd86bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------ | |
// ♥ settings ♥ | |
// ------------ | |
settings.tabsThreshold = 0; | |
settings.smoothScroll = true; | |
settings.scrollStepSize = 200; | |
settings.scrollFriction = 0; | |
settings.startToShowEmoji = 0; | |
settings.defaultSearchEngine = 'd'; | |
// --------- | |
// ♥ hints ♥ | |
// --------- | |
api.Hints.style('font-family: arial; border: solid 1px black; color: black; background: initial; background-color: #ff6cb0; font-size: 16px;'); | |
api.Hints.style("font-family: arial; border: solid 1px #C38A22;padding: 1px;background: #f4e5ff; font-size: 16px;", "text"); | |
// ----------------- | |
// ♥ substitutions ♥ | |
// ----------------- | |
api.unmap('<Ctrl-i>'); | |
api.unmap('m'); | |
api.map("K", "R"); | |
api.map("J", "E"); | |
api.map("u", "e"); | |
api.map("H", "S"); | |
api.map("L", "D"); | |
api.map("oo", "go"); | |
api.map('F', "gf"); | |
api.map('gx]', "gx$"); | |
api.map('gx[', "gx0"); | |
api.map('gt', 'T'); | |
api.map('<Ctrl-n>', '<Tab>'); | |
api.map('<Ctrl-p>', '<Shift-Tab>'); | |
api.mapkey('mf', 'Open multiple links in a new tab', function() { | |
api.Hints.create("", api.Hints.dispatchMouseClick, { | |
multipleHits: true | |
}); | |
}); | |
// -------- | |
// ♥ zoom ♥ | |
// -------- | |
api.mapkey('<Ctrl-k>', '', function() { | |
api.RUNTIME('setZoom', { | |
zoomFactor: 0.1 | |
}); | |
}); | |
api.mapkey('<Ctrl-j>', '', function() { | |
api.RUNTIME('setZoom', { | |
zoomFactor: -0.1 | |
}); | |
}); | |
// ---------- | |
// ♥ scroll ♥ | |
// ---------- | |
api.mapkey('<Ctrl-u>', 'Scroll a page up', function() { | |
window.scrollTo({ | |
top: window.scrollY - window.innerHeight, | |
behavior: 'smooth' | |
}); | |
}, { | |
repeatIgnore: false | |
}); | |
api.mapkey('<Ctrl-d>', 'Scroll a page down', function() { | |
window.scrollTo({ | |
top: window.scrollY + window.innerHeight, | |
behavior: 'smooth' | |
}); | |
}, { | |
repeatIgnore: false | |
}); | |
// -------------- | |
// ♥ combo/list ♥ | |
// -------------- | |
api.mapkey('ca', 'Mouse over expandables.', () => api.Hints.create('select, button[aria-expanded="false"]', api.Hints.dispatchMouseClick, { | |
mouseEvents: ['mouseover'] | |
})); | |
api.mapkey('cA', 'Click expandables.', () => api.Hints.create('select, button[aria-expanded="false"]', api.Hints.dispatchMouseClick)); | |
// ----------------------------- | |
// ♥ kill all tabs, launch url ♥ | |
// ----------------------------- | |
api.mapkey('zz', 'Homepage', function() { | |
api.RUNTIME('tabOnly'); | |
api.tabOpenLink('chrome://newtab/'); | |
api.RUNTIME('closeTab'); | |
}); | |
// ---------------- | |
// ♥ autocomplete ♥ | |
// ---------------- | |
var autoCompleteGoogle = { | |
parser: function(response) { | |
var res = JSON.parse(response.text); | |
return res[1] | |
}, | |
url: 'https://www.google.com/complete/search?client=firefox&ds=yt&q=' | |
}; | |
var autoCompleteAmazonGlobal = { | |
parser: function(response) { | |
var res = JSON.parse(response.text); | |
var res = res["suggestions"].map(item => item.value); | |
return res.filter((v, i, a) => a.indexOf(v) === i); | |
}, | |
url: 'https://completion.amazon.com/api/2017/suggestions?limit=11&suggestion-type=WIDGET&suggestion-type=KEYWORD&page-type=Search&alias=aps&site-variant=desktop&version=2&event=onKeyPress&wc=&lop=en_CA&fb=1&plain-mid=7&client-info=amazon-search-ui&prefix=' | |
} | |
var autoCompleteAmazonCA = { | |
parser: function(response) { | |
var res = JSON.parse(response.text); | |
var res = res["suggestions"].map(item => item.value); | |
return res.filter((v, i, a) => a.indexOf(v) === i); | |
}, | |
url: 'https://completion.amazon.ca/api/2017/suggestions?limit=11&suggestion-type=WIDGET&suggestion-type=KEYWORD&page-type=Search&alias=aps&site-variant=desktop&version=2&event=onKeyPress&wc=&lop=en_CA&fb=1&plain-mid=7&client-info=amazon-search-ui&prefix=' | |
} | |
var autoCompleteSquishmallows = { | |
parser: function(response) { | |
var res = JSON.parse(response.text); | |
return res["suggestions"]; | |
}, | |
url: 'https://squishmallowsquad.fandom.com/wikia.php?controller=UnifiedSearchSuggestionsController&method=getSuggestions&format=json&query=' | |
} | |
var autoCompleteDuckDuckGo = { | |
parser: function(response) { | |
var res = JSON.parse(response.text); | |
return res.map(item => item.phrase); | |
}, | |
url: 'https://duckduckgo.com/ac/?kl=wt-wt&q=' | |
} | |
var autoCompleteYouTube = { | |
parser: function(response) { | |
var res = response.text; | |
res = res.slice(res.indexOf('[')); | |
res = res.slice(0, res.lastIndexOf(']') + 1); | |
return JSON.parse(res)[1].map(item => item[0]); | |
}, | |
url: 'https://suggestqueries-clients6.youtube.com/complete/search?client=youtube&ds=yt&q=' | |
} | |
var defaultAutoComplete = autoCompleteGoogle; | |
// ------------------ | |
// ♥ search helpers ♥ | |
// ------------------ | |
var addSearch = function(letter, name, description, url, autoComplete) { | |
var autoComplete = (autoComplete === undefined) ? defaultAutoComplete : autoComplete; | |
api.addSearchAlias(letter, name, url, 's', autoComplete.url, autoComplete.parser); | |
api.mapkey('o' + letter, description, function() { | |
api.Front.openOmnibar({ | |
type: "SearchEngine", | |
extra: letter | |
}); | |
}); | |
}; | |
// ------------------ | |
// ♥ search engines ♥ | |
// ------------------ | |
api.removeSearchAlias('h'); | |
api.removeSearchAlias('b'); | |
api.removeSearchAlias('d'); | |
api.removeSearchAlias('s'); | |
addSearch('y', 'YouTube', 'Search YouTube', 'https://www.youtube.com/results?search_query=', autoCompleteYouTube); | |
addSearch('l', 'Lucky Search', 'Google Lucky Search', 'http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q='); | |
addSearch('e', 'eBay', 'Search eBay', 'https://www.ebay.com/sch/i.html?_nkw='); | |
addSearch('sr', 'Subreddit', 'Search Subreddit', 'https://www.reddit.com/subreddits/search?q='); | |
addSearch('r', 'Reddit', 'Search Reddit', 'https://www.reddit.com/search/?q='); | |
addSearch('w', 'Wolfram Alpha', 'Search Wolfram Alpha', 'https://www.wolframalpha.com/input/?i='); | |
addSearch('tr', 'Reverso Translate', 'Translate', 'https://context.reverso.net/translation/english-hebrew/'); | |
addSearch('sl', 'SL Marketplace', 'Search SL Marketplace', 'https://marketplace.secondlife.com/products/search?utf8=%E2%9C%93&search%5Bcategory_id%5D=&search%5Bmaturity_level%5D=GMA&search%5Bkeywords%5D='); | |
addSearch('sq', 'Squishmallows', 'Squishmallows Wiki', 'https://squishmallowsquad.fandom.com/wiki/', autoCompleteSquishmallows); | |
addSearch('ag', 'Search Amazon Global', 'Amazon Global', 'https://www.amazon.com/s?k=', autoCompleteAmazonGlobal); | |
addSearch('ac', 'Search Amazon CA', 'Amazon CA', 'https://www.amazon.ca/s?k=', autoCompleteAmazonCA); | |
addSearch('d', 'Search DuckDuckGo', 'DuckDuckGo', 'https://duckduckgo.com/?q=', autoCompleteDuckDuckGo); | |
// ------------- | |
// ♥ clipboard ♥ | |
// ------------- | |
function openLink(urls, inNewTab) { | |
var urlReg = /^(?:https?:\/\/)?[\w-_]+(?:\.[\w-_]+)+.*/im, | |
pReg = /^[\w-]+?:\/\//i; | |
urls.trim().split('\n').slice(0, 5).forEach(function(url) { | |
url = url.trim(); | |
if (url.length > 0) { | |
if (urlReg.test(url)) { | |
if (!pReg.test(url)) { | |
url = "http://" + url; | |
} | |
} else { | |
url = 'https://duckduckgo.com/?q=' + url; | |
} | |
api.RUNTIME("openLink", { | |
tab: { | |
tabbed: inNewTab | |
}, | |
url: url | |
}); | |
} | |
}); | |
}; | |
api.mapkey('yt', "Copy current page's title", function() { | |
api.Clipboard.write(document.title) | |
}); | |
api.mapkey('p', 'Open selected link or link from clipboard in current tab', function() { | |
if (window.getSelection().toString()) { | |
openLink(window.getSelection().toString(), false); | |
} else { | |
api.Clipboard.read(function(response) { | |
openLink(response.data, false); | |
}); | |
} | |
}); | |
api.mapkey('P', 'Open selected link or link from clipboard in new tab', function() { | |
if (window.getSelection().toString()) { | |
openLink(window.getSelection().toString(), true); | |
} else { | |
api.Clipboard.read(function(response) { | |
openLink(response.data, true); | |
}); | |
} | |
}); | |
// -------------- | |
// ♥ image zoom ♥ | |
// -------------- | |
var createZoomModal = function(element) { | |
var imageZoomWindow = document.createElement('div'); | |
imageZoomWindow.style.cssText = ` | |
display: block; | |
position: fixed; | |
z-index: 999999; | |
left: 0; | |
top: 0; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
background-color: rgba(0,0,0,0.9); | |
transform: scale(0); | |
transition: 0.5s; | |
` | |
var imageZoom = document.createElement('img'); | |
imageZoom.setAttribute('alt', element.alt); | |
imageZoom.style.cssText = ` | |
height: 100%; | |
width: 100%; | |
object-fit: contain; | |
overflow: hidden; | |
` | |
var src = element.src; | |
var srcset = element.srcset; | |
var type = element.tagName; | |
if (type == "DIV") { | |
if(element.getAttribute("data-bgset")) | |
srcset = element.getAttribute("data-bgset"); | |
} | |
if (src) | |
imageZoom.setAttribute('src', src); | |
else { | |
const parts = srcset.trim().split(/,/); | |
const lengths = parts.map(e => e.trim().split(' ')[1]); | |
const slicedLengths = lengths.map(e => parseInt(e.slice(0, -1))); | |
const index = slicedLengths.indexOf(Math.max(... slicedLengths)); | |
const src = parts.map(e => e.trim().split(' ')[0])[index]; | |
imageZoom.setAttribute('src', src); | |
} | |
var imageLink = document.createElement('a'); | |
imageLink.onclick = function() { | |
imageZoomWindow.remove(); | |
}; | |
imageLink.appendChild(imageZoom); | |
imageZoomWindow.appendChild(imageLink); | |
document.body.appendChild(imageZoomWindow); | |
setTimeout(() => imageZoomWindow.style.transform = 'scale(1)'); | |
}; | |
api.mapkey(';zi', '', function() { | |
api.Hints.create('img, .grid_img, .ss_img', function(element) { | |
createZoomModal(element); | |
}); | |
}); | |
// --------- | |
// ♥ theme ♥ | |
// --------- | |
settings.theme = ` | |
#sk_omnibarSearchResult ul li { | |
overflow-y: auto; | |
overflow-x: hidden; | |
color: white; | |
} | |
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) { | |
background: #393939; | |
color: white; | |
} | |
.sk_theme .url { | |
color: white; | |
} | |
#sk_omnibar { | |
background: #3e3e3e; | |
font-size: 14px; | |
} | |
.sk_theme #sk_omnibarSearchResult ul li.focused { | |
background: #8a3b7f; | |
} | |
#sk_omnibarSearchArea input { | |
color: white; | |
} | |
.sk_theme .omnibar_timestamp { | |
color: #ffbde7; | |
} | |
#sk_omnibarSearchResult li div.title { | |
color: white; | |
font-family: sans-serif, 'emoji' | |
} | |
.sk_theme .omnibar_folder { | |
color: #c5bff7; | |
} | |
.sk_theme .omnibar_highlight { | |
color: #00ff8b; | |
} | |
.expandRichHints kbd { | |
font-size: 18px; | |
padding: 3px 3px; | |
margin-bottom: 3px; | |
} | |
#sk_keystroke, #sk_usage { | |
background: #3e3e3e; | |
font-size: 16px; | |
} | |
.sk_theme .annotation { | |
color: white; | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment