Skip to content

Instantly share code, notes, and snippets.

@kordless
Created March 17, 2022 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kordless/a58c5605e947975d5c0c5ccea0df6d85 to your computer and use it in GitHub Desktop.
Save kordless/a58c5605e947975d5c0c5ccea0df6d85 to your computer and use it in GitHub Desktop.
// google docs app
var line = "{{line}}";
if ("{{text}}" == "" && "{{view}}" == "") {
// just nothing
url = "https://docs.google.com/";
} else if ("{{text}}" == "" && "{{view}}" != ""){
// view
var view = "{{view}}".substring(1); // trim the | off (fix this)
if (view == "sheets") {
url = "https://docs.google.com/spreadsheets/u/0";
} else if (view == "slides") {
url = "https://docs.google.com/presentation/u/0";
} else if (view == "forms") {
url = "https://docs.google.com/forms/u/0";
} else {
url = "https://docs.google.com/document/u/0";
}
} else if ("{{text}}" != "" && "{{view}}" != "") {
// search and view
var view = "{{view}}".substring(1); // trim the | off (fix this)
if(view == "sheets") {
url = "https://docs.google.com/spreadsheets/u/0/?q={{text}}";
} else if (view == "slides") {
url = "https://docs.google.com/presentation/u/0/?q={{text}}";
} else if (view == "forms") {
url = "https://docs.google.com/forms/u/0/?q={{text}}";
} else {
url = "https://docs.google.com/document/u/0/?q={{text}}"; // docs
}
} else {
// search, no view
url = "https://docs.google.com/document/u/0/?q={{text}}";
}
// go and report
window.open(url);
controller.report(Sidekick_HTML('Opening <a style="text-decoration: underline; color: #bb99bb;" id="link-{{target_id}}" href="'+url+'">'+url+'</a> <a id="crawl-{{target_id}}" href>💾</a>'));
var timer = setTimeout(function(){
// set clicking
$('#link-{{target_id}}').click(function(){
window.open(url);
});
$('#crawl-{{target_id}}').click(function(){
controller.report(Sidekick("!crawl "+url));
BotAias("null", "!crawl "+url);
});
},123);
Scroll();
"{{app_id}}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment