If I understand correctly, the problem consists of substituting remote
stylesheets by local ones.
One way to achieving this would be replicating the remote author
styles by user styles with the !important directive. For this specific
example, where the stlyes sheets are huge and complex, this seem not
very practicable.
A better way would be
a) to prevent the remote stylesheets from loading, and
b) to force Firefox to use the local ones instead.
For part 'a' different solutions are possible: the 'hosts' file, a
proxy server, the AdBlock extension, etc. It turns out that Firefox
comes with a built-in method for preventing stylesheets from loading,
it is called Permission Manager [1] [2]. Unfortunatelly there is no UI
for this in Firefox as of today. Until Firefox 2, it was possible to
maintain permissions by editing the plain text file 'hostperm.1' in
the profile directory. The appropriate entry would be:
hosts s1.travian.ir stylessheets 2
The word 'hosts' was fixed, then followed a domain, then a type of
resource and finally a digit which stood for the permission itself. In
this case '2' meant 'block', so the whole entry meant 'block all
stylesheets hosted at s1.travian.ir'.
With the advent of Firefox 3, this was changed to a (binary) sqlite
database file, the 'permissions.sqlite' file in the profile directory.
In order to insert a row into the appropriate table you can for
example use the sqlite standalone executable [3], or you can install
the SQLite Manager extension [4], which I recommend. If you don't
want to install sqlite or the extension just for this, there is still
a workaround: invoke the Firefox javascript console, paste the
following code into the input field, and click on 'evaluate'. This
has the effect of executing the code in chrome context; it inserts the
above row into the permissions sql database:
var dbFile =
Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD",
Components.interfaces.nsIFile); dbFile.append("permissions.sqlite");
var storageService =
Components.classes["@mozilla.org/storage/service;1"].getService(Components.interfaces.mozIStorageService);
var dbConn = storageService.openDatabase(dbFile);
dbConn.executeSimpleSQL( "INSERT INTO moz_hosts (host,type,permission)
VALUES ('s1.travian.ir','stylesheet',2)"); dbConn.close();
For the part 'b', the extension-less solution is just adding a
site-specifc style into the 'userContent.css' file or your chrome
folder (under the profile folder, see [5]). If there is no
'userContent.css', create it.
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("s1.travian.ir") {
/*
Here copy the contents of
http://s1.travian.ir/gpack/travian_default/lang/ir/compact.css?fnnnn
and
http://s1.travian.ir/gpack/travian_default/lang/ir/lang.css?fnnnn
*/
}
Alternatively you can use a CSS @import directive and have the whole
stuff in separate files. This requires however that the @import
directive(s) be the very first line(s) in userContent.css.
Infinitely more comfortable than this is using the Stylish
extension[6], which I also recommend. With Stylish you can define and
maintain individual styles for specific domains, very much in the way
of Greasemonkey.
[1] https://wiki.mozilla.org/User:Mvl/permissions
[2] http://kb.mozillazine.org/Hostperm.1
[3] http://www.sqlite.org/download.html
[4] https://addons.mozilla.org/en-US/firefox/addon/5817
[5] http://www.mozilla.org/unix/customizing.html#usercss
[6] https://addons.mozilla.org/ca/firefox/addon/2108
On Sun, Aug 2, 2009 at 10:59 PM, RodMcguire<[email protected]> wrote:
>
>
>
> On Aug 2, 1:58 pm, qufighter <[email protected]> wrote:
> ...
>> However if you wish to save bandwidth, you would need some way to
>> block all CSS files from a particular domain, which sounds like a
>> great plugin but I can't find anything like this. If you simply
>> disable CSS then GM_addStyle may not function.
>>
>> What you really need is a way to change the CSS paths before they
>> download, and Firefox usually tries to retrieve them as soon as it
>> encounters the files in the header, while GM doesn't run until page
>> load (after CSS download). You might be able to pull this off with an
>> extension.
>>
> The Adblock Plus extension can keep .css files from loading.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---