User:Dipankan001/freesearch.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Dipankan001/freesearch. |
importScriptURI('http://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()', 'Search free images', 'tb-freesearch', 'Find free images using Google'); //Add link in toolbox
}
function freesearch_form(){
var floatbox = new Floatbox("Find free images using Google (Version by Dipankan001)");
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 = "Search free images";
}
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"));
}