google search saves+download

try to take over the world!

// ==UserScript==
// @name         google search saves+download
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       You
// @include        *
// @include        google.com/search?
// @require https://code.jquery.com/jquery-3.4.1.js
// @grant        none
// ==/UserScript==
(function download() {var textFile = null,makeTextFile = function (text) {var data = new Blob([text], { type: 'text/plain' });if (textFile !== null) {window.URL.revokeObjectURL(textFile);};textFile = window.URL.createObjectURL(data);return textFile;};var create = document.createElement('button'),textbox = make('textarea','file',null),filetype = make('input','filename',null),ch=[],k=[];filetype.size=5;create.id='download';create.innerText='download serch';setTimeout(function(){if(window.location.href.includes('.com/search?')){$('.gLFyf.gsfi')[0].parentElement.parentElement.parentElement.parentElement.appendChild(create);$('.gLFyf.gsfi')[0].parentElement.parentElement.parentElement.parentElement.appendChild(filetype);ch=document.getElementById('select').children;ch.forEach=[].forEach;ch.forEach(e=>{k.push(e.innerText);});k=k.join('\n');textbox.value=k;}},1100);create.addEventListener('click', function () {var link = document.createElement('a'); link.href = makeTextFile(textbox.value); link.style.display = 'none';link.download = filetype.value;link.click();link.style.display = 'none';link.remove();}, false);})();function setCookie(cname,cvalue,exdays) {var d = new Date();d.setTime(d.getTime() + (exdays*24*60*60*1000));var expires = "expires=" + d.toGMTString();document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";};function getCookie(cname) {var name = cname + "=";var decodedCookie = decodeURIComponent(document.cookie);var ca = decodedCookie.split(';'); for(var i = 0; i < ca.length; i++) {var c = ca[i];while (c.charAt(0) == ' ') {c = c.substring(1);}if (c.indexOf(name) == 0) {return c.substring(name.length, c.length);}}return "";};function removeDups(names) {let unique = {};names.forEach(function(i) {if(!unique[i]) {unique[i] = true; }});return Object.keys(unique);};function checkCookie(n,after) {var user=getCookie(n);if (user != "") {console.log(user,true);return user;} else {user = after;if (user != "" && user != null) {setCookie(n, user, 30);return false;}}};function make(tag,id,classname){var element=document.createElement(tag.toString());element.id=id;element.classname=classname;return element;};function ggsearhes(){if(window.location.href.includes('google.com/search?')){setTimeout(function(){var serch=$('.gLFyf.gsfi')[0], select=document.createElement('select'),button=document.createElement('button'),a,b, loc,num=0;button.onclick=function(){window.location=loc;};select.size=1;select.id='select';var p=serch.parentElement.parentElement.parentElement.parentElement,count=0, sent=(checkCookie('y5',serch.value)).toString();sent=(checkCookie('y5',serch.value)).toString();sent=(sent);sent=sent.split(',');sent.push(serch.value);sent=removeDups(sent);setCookie('y5', sent, 30);var k=[];function sortNumber(a, b) {console.log(a,b);return b[1]-a[1] ;}sent.forEach(e=>{var op=document.createElement('option');op.value=count;op.id=e;op.innerText=e;console.log(op);k.push([op,count]);count++});k.sort(sortNumber);k.forEach(e=>{select.append(e[0]);});var span=document.createElement('span');span.innerText='serches ';span.id='span';button.innerText='Go here';button.id='butotn';if(!document.getElementById('span')){p.append(span);}if(!document.getElementById('select')){p.append(select)};if(!document.getElementById('button')){p.append(button)};$(select).on('change', function(e) {if ($(this).val() == 'selectionKey'){} else {console.log('changed',true);select.children.forEach=[].forEach;select.children.forEach(e=>{if(e.selected){a= e};console.log(e,e.selected)});console.log(a); b=a.innerText.toString().split(' ').join('+');loc=`https://www.google.com/search?q=${a}`;serch.value=a.innerText}});},1000);}};function sites(){var site=document.domain;var select=document.createElement('select');select.size=1;var button=document.createElement('button');var a;var b;var loc;var num=0;button.onclick=function(){window.location=loc;};select.id='select2';button.id='button2';var p;if(window.location.href.includes('.com/search?')){p=$('.gLFyf.gsfi')[0].parentElement.parentElement.parentElement.parentElement;}site=document.domain;var count=0;var sent=(checkCookie('sites',site)).toString();sent=(checkCookie('sites',site)).toString();sent=(sent);sent=sent.split(',');sent.push(site);sent=removeDups(sent);setCookie('sites', sent, 30);console.log([site,select,sent,num,button,a,b,loc,p])};ggsearhes();setTimeout(sites,2000)