Discussions » Development

Problem with @exclude

§
Posted: 2014-06-11

Problem with @exclude

I have been customising a script that allows a background image for Google search. However, I would like the image to display on the Google homepage ONLY, and not to appear when Google presents its results.

My include line is:

// @include https://www.google.co.uk/


I noticed that when a search term (for example: Bubwith) is entered in Google and Enter is pressed, the results URL is in the form:

https://www.google.co.uk/#q=Bubwith&safe=off

So I tried:

//@exclude https://www.google.co.uk/#q=*

This does not work, and the background image still displays on the results pages.

Is there a trick to this?

Full script below


Cheers

Rock









// ==UserScript==
// @name My Google Logo
// @author Ross Walker
// @namespace http://localhost/
// @description Change the Google logo with your own file or hosted image
// @version 1
// @include https://www.google.co.uk/
// @exclude https://www.google.co.uk/#q=*
// @resource filebg anubia.jpg
// @resource filelogo google1.png
// ==/UserScript==

// ---------------------------------------------------------------------------------------------------
// Add a custom LOGO from a local file on your hard drive or an image online
//
var oldLogo = document.getElementById('hplogo');
var newLogo = document.createElement('img');
newLogo.id = "User-Logo";
newLogo.border = 'no'

// Uncomment the following line for a local background image file which is in the same location as this .js javascript script - edit the name of the file in the internet address in the filelogo resource section at the top
newLogo.src = GM_getResourceURL ("filelogo");

// Replace the logo
oldLogo.parentNode.replaceChild(newLogo, oldLogo);
// ----------------------------------------------------------------------------------------------------
//
// Add a custom BACKGROUND from a local file on your hard drive or an image online
//
var b = document.body;

// Uncomment the following line for a local background image file which is in the same location as this .js javascript script - edit the name of the file in the internet address in the filebg resource section at the top
b.style.background = '#ccc url("' + GM_getResourceURL ("filebg") + '") no-repeat top left';

// Set the size of the image to fit
b.style.backgroundSize = "100% 102%";

§
Posted: 2014-06-11

I believe Greasemonkey only applies scripts on actual page load. Google does some JavaScript and changes the URL to include a hash, but doesn't actually do a page load.

Perhaps you would need to watch for this event?

§
Posted: 2014-06-11

There a div#lga across the center of the home page that contains the Google logo. It gets deleted when results are added to the page. Maybe you can do something with that element, such as make it the full size of the viewport and assign your background image to it. I haven't tried it myself.

Post reply

Sign in to post a reply.