Google background script - Where am I going wrong?

301 views
Skip to first unread message

aneesh99

unread,
Nov 4, 2012, 6:00:15 PM11/4/12
to greasemon...@googlegroups.com
I've tried running this script in Chrome to change up the Google homepage logo and background but to no avail (with the Nov 16th situation). Can anyone see where I'm going wrong? 

// ==UserScript==
// @name          Google BG
// @author        12345
// @namespace     http://localhost/
// @description   Google BG
// @version       1
// @include       http://*.google.*/*
// @include       https://*.google.*/*
// @resource      filebg nature.jpg
// @resource      filelogo google.png
// ==/UserScript==
// --------------------------------------------------------------------------------------------------------------------------------
var oldLogo = document.getElementById('hplogo');
var newLogo = document.createElement('img');
newLogo.id = "User-Logo";
newLogo.border = 'no'
newLogo.src = GM_getResourceURL ("filelogo");
oldLogo.parentNode.replaceChild(newLogo, oldLogo);
// --------------------------------------------------------------------------------------------------------------------------------
//
var b = document.body;
b.style.background = '#ccc url("' + GM_getResourceURL ("filebg") + '") no-repeat top left';
b.style.backgroundSize = "100% 102%";


The local images are in the extension folder belonging to the scipt with the correct names (i.e nature.jpg and google.png). Going to https://www.google.co.uk/ gives me the normal homepage. 

aneesh99

unread,
Nov 4, 2012, 6:07:50 PM11/4/12
to greasemon...@googlegroups.com
Actually, if I run the script through Tampermonkey, where can I place the images for the script? 

LWChris@LyricWiki

unread,
Nov 4, 2012, 6:09:51 PM11/4/12
to greasemon...@googlegroups.com
Am 05.11.2012 00:00, schrieb aneesh99:
> The local images are in the extension folder belonging to the scipt with
> the correct names (i.e nature.jpg and google.png). Going to
> https://www.google.co.uk/ gives me the normal homepage.

Untestet, but try to use picture names without a blank. I think that
blanks in ressource names don't work. Not sure whether you have to put
the ressource name in " then, or replace the blank with %20 or if it's
simply impossible, but that would be my first try.

Also, I guess that the "border" attribute is not "yes"/"no" but either
"true"/"false" or "1"/"0", but that's not the main problem.

Chris

Anthony Lieuallen

unread,
Nov 4, 2012, 6:18:11 PM11/4/12
to greasemon...@googlegroups.com
On Sun, Nov 4, 2012 at 6:09 PM, LWChris@LyricWiki <lwc...@gmx.de> wrote:
I think that blanks in ressource names don't work.

The resource lines as posted are correct.  First is the name of the resource, then a space, then the URL to download and make available as that name.

On Sun, Nov 4, 2012 at 6:07 PM, aneesh99 <anee...@gmail.com> wrote:
Actually, if I run the script through Tampermonkey, where can I place the images for the script? 

Don't do anything different.  A brief check seems to indicate Tampermonkey supports @resource just fine.

Your script as pasted is hard to test because it references relative URLs and isn't hosted anywhere for them to resolve to.  But this works for me:

https://gist.github.com/4014321

Go from there?

LWChris@LyricWiki

unread,
Nov 4, 2012, 6:20:13 PM11/4/12
to greasemon...@googlegroups.com
Oops sorry, I misinterpreted the ressource names as part of the file
names. Too long ago that I used GM resources.

Did you try to remove the blanks after GM_getResourceURL? If that
doesn't help, try to re-install the script by opening the .user.js file
once again. Maybe the ressources need to be registered in the
configuration xml and AFAIK that happens on installation.

Chris
Reply all
Reply to author
Forward
0 new messages