Skip to content

Instantly share code, notes, and snippets.

@jD91mZM2
Created September 10, 2017 15:15
Show Gist options
  • Save jD91mZM2/638c83f2b4c8a65392f0a8e5d36d2125 to your computer and use it in GitHub Desktop.
Save jD91mZM2/638c83f2b4c8a65392f0a8e5d36d2125 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Search -> Discord
// @version 0.2.1
// @author tbodt, improved by jD91mZM2
// @match https://www.google.se/*
// @match https://www.google.com/*
// @match https://www.google.ee/*
// @grant GM_xmlhttpRequest
// @require https://code.jquery.com/jquery-3.2.0.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
// Config
var code = "<code>";
// Config End
function logSearch() {
if (window.location.pathname == "/" || window.location.pathname == "/search") {
var search = location.hash;
if(search.length <= 0)
search = location.search;
index = search.indexOf("q=");
if (index < 0)
return;
search = search.slice(index + 2);
end = search.indexOf('&');
if (end >= 0)
search = search.substring(0, search.indexOf('&'));
search = decodeURIComponent(search.replace(/\+/g, " "));
GM_xmlhttpRequest({
method: "POST",
url: "https://krake.one/discord/google",
data: "user=" + encodeURIComponent(code) +
"&secret=22dyuR5CE5dwLpu42b1cwmmcJ7HuMD0PaaZ3nwlRTmbBEEejyhxMDxsMXxFWmWXI" +
"&message=" + encodeURIComponent(search),
onerror: function(res) {
console.log("Error making request");
},
onload: function(res) {
console.log("Sent google result: " + search + ", response: " + res.responseText);
},
headers: { "Content-Type": "application/x-www-form-urlencoded" }
});
}
}
waitForKeyElements("#ires", logSearch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment