// ==UserScript== // @name Wolfram|Alpha in Google Search // @namespace /u/iansan5653 // @include https://www.google.com/search* // @description Integrates Wolphram|Alpha search results with Google search results seamlessly. // @version 1.3 // @grant none // @icon http://cdn.altrn.tv/icons/wolfram-alpha_3195.png // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // ==/UserScript== var YOUR_APPID = "YOUR-APPIDGOESHERE"; this.$ = this.jQuery = jQuery.noConflict(true); if($(".hdtb_msel").text() == "Web") { //For example, not images var searchUrl = window.location + ''; function getQuery(sURL) { //Gets current search terms var sURLParams = sURL.split(/(\?|\&)/g); for (var i = 0; i < sURLParams.length; i++) { var sParamName = sURLParams[i].split('='); if (sParamName[0] == "q") { return sParamName[1]; } } } var query = getQuery(searchUrl); var readQuery = decodeURIComponent(query).replace(/\+/g, ' '); var boxwidth = $("#center_col").width(); var queryURL = "https://thingproxy.freeboard.io/fetch/http://api.wolframalpha.com/v2/query?input=" + query + "&appid=" + YOUR_APPID + "&format=image&reinterpret=true&podindex=1,2&width=" + boxwidth; function getHTML(tElement) { return $('

Query Wolfram|Alpha Querying…"); $.get(queryURL, function (data) { var wapods = $(data).find("pod"); var sourceURL = $(data).find("source").first().attr("url"); if (wapods.length !== 0) { $("#wabox").empty(); $("#wabox").append(getHTML($(wapods[0]).find("img").first())) .append(" ") .append(getHTML($(wapods[1]).find("img").first())); } else { $("#wabox").text("No results found."); $("#wacontainer").fadeOut(5000); } }); }); $('head').append(' '); } ').append(tElement.clone()).html(); } $("#rso").prepend(''); $("#querynow").click(function() { $("#wabox").empty(); $("#wabox").html("Querying…"); $.get(queryURL, function (data) { var wapods = $(data).find("pod"); var sourceURL = $(data).find("source").first().attr("url"); if (wapods.length !== 0) { $("#wabox").empty(); $("#wabox").append(getHTML($(wapods[0]).find("img").first())) .append("") .append(getHTML($(wapods[1]).find("img").first())); } else { $("#wabox").text("No results found."); $("#wacontainer").fadeOut(5000); } }); }); $('head').append(' '); }