Skip to content

Instantly share code, notes, and snippets.

@Yodapp
Created October 14, 2018 13:22
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 Yodapp/9bca86f42aeea20263eace86b7e18360 to your computer and use it in GitHub Desktop.
Save Yodapp/9bca86f42aeea20263eace86b7e18360 to your computer and use it in GitHub Desktop.
Prisjakt - WOX plugin
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Wox.Plugin;
namespace WOX.Prisjakt
{
public class Main : IPlugin
{
private static string prisjaktQueryUrl = "https://www.prisjakt.nu/#rparams=ss=";
public void Init(PluginInitContext context)
{
}
public List<Result> Query(Query query)
{
// GET THE QUERY THAT THE USER WANT TO SEARCH FOR
var product = query.Search;
// CREATE A RESULT TO SHOW THE LOGO AND THE QUERY AND ADD ACTION
var result = new Result
{
Title = "Search on Prisjakt...",
IcoPath = "Images\\prisjakt.png",
SubTitle = string.Format("Keyword: {0}", product),
Action = (Func<ActionContext, bool>)(c =>
{
// WHEN THE USER HITS ENTER, RUN THE METHOD
SearchPrisjakt(product);
return true;
})
};
// SHOW THE ROW WITH THE QUERY
return new List<Result> { result };
}
public void SearchPrisjakt(string query)
{
// START THE DEFAULT BROWSER AND OPEN A FORMATTED URL TO DO A SEARCH ON PRISJAKT
Process.Start(string.Format("{0}{1}", prisjaktQueryUrl, Uri.EscapeDataString(query)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment