The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

Injecting stylesheet does not work for speed dial preview

Forums » General Opera topics » User JavaScript

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

25. September 2011, 22:01:21

Injecting stylesheet does not work for speed dial preview

I want to customize the look of a certain site in speed dial. I'm not related to that site in any way, so I can't edit HTML code. I created simple user script that injects a link tag into target HTML:
// ==UserScript==
// @name			Business lynch speed dial prettifier
// @version			2011-09-26
// @namespace		http://n0rd.com
// @author			Andrey Grigororyev
// @description		Custom speed dial view for business lynch
// @include			http://www.artlebedev.ru/kovodstvo/business-lynch/*
// ==/UserScript==

(function()
{

var st = document.createElement("link");
st.rel = "stylesheet";
st.type = "text/css";
st.href = "http://hg.n0rd.com/bl.css";
st.media = "(view-mode:minimized)";
//st.media = "all";

var head = document.getElementsByTagName("head")[0];
head.appendChild(st);

})();

File is saved at user.js folder and processed correctly by Opera.

That "bl.css" content at this moment is simply:
body  
{
      background-color: black;
}


The problem is that I don't see expected black background in speed dial preview. If I set st.media to "all" I see that background becomes black when viewing page normally, but it is still white when I reload page's speed dial preview.

I suppose user.js scripts are not loaded when generating Speed dial preview. Is that correct? If yes, how should I do it then?

30. September 2011, 05:58:42

spadija

Posts: 1643

Maybe use an extension? I think I saw an extension that injected itself into speed dial previews, though I'm not entirely sure.

Forums » General Opera topics » User JavaScript