Created
March 19, 2020 17:48
-
-
Save kevinashworth/81dd9d67eb8858309dab0a2990f21ba4 to your computer and use it in GitHub Desktop.
Shortwave plus gs
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
SISW(); | |
function SISW() { | |
var t = window.getSelection | |
? window.getSelection() | |
: ( | |
document.getSelection | |
? document.getSelection() | |
: ( | |
document.selection | |
? document.selection.createRange().text | |
: '')); | |
var c = window.prompt('Type `help` for a list of commands:'); | |
if (t != '') { | |
if (c) { | |
c += ' ' + t; | |
} else { | |
c = '' + t; | |
}; | |
}; | |
if (c.indexOf('gs ') == 0) { | |
url = new URL(window.location.href); | |
tld = url.host; | |
q = c.substring(c.indexOf(' ')).trim(); | |
g = `https://www.google.com/search?q=site%3A${tld}+${q}`; | |
window.location = g; | |
} else if (c) { | |
var u = 'http://shortwaveapp.com/?go&c=' + c + '&t=' + ( | |
document.title | |
? encodeURI(document.title) | |
: '') + '&s=INSERT_CUSTOM_COMMANDS_FILE_URL_HERE'; | |
if (c.substring(0, 1) == ' ') { | |
var w = window.open(u); | |
w.focus(); | |
} else { | |
window.location.href = u; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My addition starts at line 20