Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Adding google link to startpage search engine

+0
−0

I recently switched from DuckDuckGo to startpage as my primary search engine. I was using the firefox addon duckduck-go-google to add a google link to the DuckDuckGo search results - just in case it didn't have the results I was looking for:

Screenshot of the DuckDuckGo search bar. On the right hand side, a red circle marks the location of a google logo

Is it possible to add a similar link to the startpage?

History

0 comment threads

1 answer

+0
−0

The following tampermonkey user script is puzzled together from fragments of other scripts and some AI. It is probably not the best solution, but it seems to work:

// ==UserScript==
// @name         Add Google Search Link to Startpage
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a link to Google search with the same keywords on the Startpage.com search page
// @author       Your Name
// @match        https://www.startpage.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to add a Google search link with colored letters
    function addGoogleSearchLinkWithColoredLetters() {
        console.log('Adding Google search link with colored letters...'); // Debug message

        // Create a new div element for the link
        var googleLinkDiv = document.createElement('div');
        googleLinkDiv.style.margin = '0px 0 0px 40px'; // Added left margin to move right

        // Find the search input field
        var searchInput = document.querySelector('.search-form-input');

        if (searchInput) {
            // Get the search keywords
            var searchKeywords = searchInput.value;

            // Create a new span element for each letter in "Google" with specific colors
            var googleText = document.createElement('span');
            googleText.textContent = 'G';

            var o1Text = document.createElement('span');
            o1Text.textContent = 'o';

            var o2Text = document.createElement('span');
            o2Text.textContent = 'o';

            var gText = document.createElement('span');
            gText.textContent = 'g';

            var lText = document.createElement('span');
            lText.textContent = 'l';

            var eText = document.createElement('span');
            eText.textContent = 'e';

            // Apply colors to each letter
            googleText.style.color = '#4285F4'; // Blue
            o1Text.style.color = '#EA4335'; // Red
            o2Text.style.color = '#FBBC05'; // Yellow
            gText.style.color = '#4285F4'; // Blue
            lText.style.color = '#34A853'; // Green
            eText.style.color = '#EA4335'; // Red

            // Create a new anchor element for the link
            var googleLink = document.createElement('a');
            googleLink.href = 'https://www.google.com/search?q=' + encodeURIComponent(searchKeywords);
            googleLink.style.textDecoration = 'none'; // No underline

            // Append the colored letters to the link
            googleLink.appendChild(googleText);
            googleLink.appendChild(o1Text);
            googleLink.appendChild(o2Text);
            googleLink.appendChild(gText);
            googleLink.appendChild(lText);
            googleLink.appendChild(eText);

            // Append the link to the div
            googleLinkDiv.appendChild(googleLink);

            // Find the blog menu button container
            var blogMenuButton = document.querySelector('.blog-menu-button');

            // Insert the link after the blog menu button container
            if (blogMenuButton) {
                blogMenuButton.parentNode.insertBefore(googleLinkDiv, blogMenuButton.nextSibling);
                console.log('Google search link with colored letters added successfully.'); // Debug message
            } else {
                console.log('Blog menu button container not found.'); // Debug message
            }
        } else {
            console.log('Search input field not found.'); // Debug message
        }
    }

    // Use MutationObserver to wait for the body element to be fully loaded
    var observer = new MutationObserver(function(mutations) {
        if (document.body) {
            addGoogleSearchLinkWithColoredLetters();
            observer.disconnect(); // Stop observing once the body is found
        }
    });

    // Start observing the document body for changes
    observer.observe(document.documentElement, { childList: true, subtree: true });
})();

Screenshot of the startpage search bar. On the right hand site, the word "Google" is marked with a red ellipse

History

0 comment threads

Sign up to answer this question »