Doodletoo

Image search as a reference for doodletoo

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name     Doodletoo
// @version  1
// @grant    none
// @match    http://www.doodletoo.com/*
// @author   TheOriginalBob
// @description Image search as a reference for doodletoo
// @namespace https://greasyfork.org/users/169540
// ==/UserScript==

var inputText = document.createElement('input');
inputText.id = 'searchInput';
inputText.setAttribute('type','text');
inputText.style.position = 'fixed';
inputText.style.zIndex = 1000;
inputText.style.top = '650px';
inputText.style.left = '10px';

document.getElementById('shadow').appendChild(inputText);

var imageResult = document.createElement('img');
imageResult.id = 'imageResult';
imageResult.style.position = 'fixed';
imageResult.style.zIndex = 1000;
imageResult.style.top = '400px';
imageResult.style.left = '10px';
imageResult.style.width = '400px';
imageResult.style.height = '250px';

document.getElementById('shadow').appendChild(imageResult);

imageResult.addEventListener('click',function(ele){
	imageResult.style.display = 'none';
});

inputText.addEventListener('keyup', function(ele){
	if (ele.keyCode == 13) {
    var xmlHttp = new XMLHttpRequest();
 	 	xmlHttp.open('GET', "https://api.qwant.com/api/search/images?count=1&offset=0&q=" + inputText.value,false);
  	xmlHttp.send();
  	var result = JSON.parse(xmlHttp.responseText);
    if (result.status == 'error') {
  		return alert('An Error Occured While Getting Image');
  	} else {
  		result = result.data.result.items[0].media;
  	}
    imageResult.setAttribute('src',result);
    imageResult.style.display = ''
  	inputText.value = null;
  }
});