DEV Community

Discussion on: Metasearch engine in html + google a great utility

Collapse
 
crs1138 profile image
Honza

Hey, how about a little syntax improvement to make changing the server list a wee bit more user friendly?

function process(){
    const servers = [
        'https://digitalocean.com',
        'https://teleconnector.com',
        'https://dev.to',
        'https://www.omgubuntu.co.uk/',
        'http://ubuntuhandbook.org',
        'https://vitux.com/',
        'https://www.techdrivein.com/',
        'https://www.linuxbabe.com/',
        'http://www.webupd8.org/',
        'https://www.scaleway.com/',
        'https://linuxconfig.org',
        'https://upcloud.com/',
        'https://www.techrepublic.com/',
        'https://vitux.com/',
        'https://www.cyberciti.biz/',
        'ovh.com',
        'http://www.penguintutor.com/',
        'https://www.tecmint.com/',
    ];

    function getServerString( arr) {
        return `site:${arr.join(`+OR+site:`)}`;
    }
    const searchString = document.getElementById("url").value

    const url = `https://www.google.com/search?q=${searchString} ${getServerString(servers)}`;

    window.open(url);
    return false;
}
Collapse
 
cemkaanguru profile image
cem kaan kosali • Edited

I wish there was a codepen for it.
...
oh there it is
codepen.io/kaanna/pen/pojZMxz

Collapse
 
crs1138 profile image
Honza

I think we could clean it up a wee bit 😉
codepen.io/crs1138/pen/abvazyd

Collapse
 
manishfoodtechs profile image
manish srivastava

Wow Honza .... wonderful. Thanks

Collapse
 
mounirb profile image
Mounir Bennacer

why not going further and take google's results and put them on your own site ? lol