User:AFigureOfBlue/freesearch.js
(Redirected from User:Drilnoth/freesearch.js)
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:AFigureOfBlue/freesearch. |
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Drilnoth/toolkit.js&action=raw&ctype=text/javascript');
addOnloadHook(start_freesearch); //Initiates the script on page load
function start_freesearch(){ //Begins the script
mw.util.addPortletLink('p-tb', 'javascript:freesearch_form()', 'Free image search', 'tb-freesearch', 'Find free images using Google'); //Add link in toolbox
}
function freesearch_form(){
var floatbox = new Floatbox("Google Free Image Search");
var mainform = floatbox.create_form();
mainform.setAttribute("action", "javascript:freesearch_eval();");
var searchterm = floatbox.form_input("text", "searchterm");
searchterm.value = wgTitle;
floatbox.form_append("label", "Search term(s)");
floatbox.form_append("br");
var submitbutton = floatbox.form_input("submit", "submit");
submitbutton.value = "Submit";
}
function freesearch_eval(){
var w = window.open("http://images.google.com/images?as_rights=(cc_publicdomain|cc_attribute|cc_sharealike).-(cc_noncommercial|cc_nonderived)&as_eq=wikipedia+wikimedia&as_q=" + enc(id("floatbox-floatform").searchterm.value));
id("content").removeChild(id("floatbox-main"));
}