|
| Edit Site Specific CSS script |
 |
Sun, 17 Jun 2007 13:26:05 +010 |
I found creating and editing Site Specific CSS a pain in the rear. I
wrote a simple AutoIt3 script that makes it a bit easier (AutoIt3 is
only available for Windows).
After the mod you'll have a "Edit site user CSS" function on the menu
that appears when you right click on a web page. If no site specific
user CSS file is found a blank file will open in your editor with the
site's host name as the suggested file name. If one exists already it
will open the existing file.
For newly created files you then have to select "Edit site
preferences"
from the right click menu, select the "Display" tab and select the
newly
created file as "My style sheet" with the "Choose" button.
Sadly afaics this last step cannot be automated by script since Opera
loads the override.ini file into memory on startup where any changes to
it are made, these are then written back to disk on program close (or
when changes are made to it?). Any changes made by a script would
therefore get lost.
Instructions:
Download and install AutoIt3 http://www.autoitscript.com/autoit3/
Open Opera's language file (e.g. english.lng)
Find this entry:
; Page context menu option to edit preferences for current site.
385004252="Edit site preferences..."
Add this beneath it:
; Page context menu option to edit user CSS for current site.
999999999="Edit site user CSS"
Save and close the file.
Open your menu ini file (create a custom one if you don't already have
one), e.g. \profiles\menu\standard_menu (1).ini
Find this:
Item, 385004252=Edit site preferences
Add this beneath it:
Item, 999999999="Execute program,
"c:\apps\opera\EditSiteUserCSS.au3", "%U", ,
"EditSiteUserCSS""
(change the path to suit your system and remove the line break)
Open your text editor and copy the following script code into it:
; Start script --------------------------------------------------------
; Path variables
$sEditor = "c:\apps\ultraedit\uedit32.exe"
$sIni = "c:\apps\opera\profile\override.ini"
$sStyles = "c:\apps\opera\styles\"
;---------------------------------------------------
; Extract the domain from the URL
$sVar = StringSplit($CmdLine[1],"://",1)
$sDomain = StringSplit($sVar[2],"/")
$sDomain = $sDomain[1]
; URL examples:
; https://host.tld/ results in host.tld
; file://localhost/ results in localhost
; http://sub.host.tld/foo/ results in sub.host.tld
; http://www.sub.host.tld/foo/ results in www.sub.host.tld
; http://www.host.tld/foo results in www.host.tld
; http://www2.host.tld/foo results in www2.host.tld
$sKey = "User Prefs|Local CSS File"
$sValue = $sStyles & $sDomain & ".css"
; Open Stylesheet in Editor
; !Note that some editors do not accept a file name if the file does
not already exist (UltraEdit works fine)
;
ShellExecute($sEditor, $sValue)
; End script --------------------------------------------------------
Change the path variables between the first and the second dotted line
to suit your system. Save the file as EditSiteUserCSS.au3 in the Opera
program dir.
That should be it (restart Opera). The domain extraction from the URL in
the script is rather simplistic and may not be 100% reliable (host.tld
and www.host.tld pointing to the same site for example). In practice it
hasn't yet caused any problems for me.
If you already have site specific user css files you'll have to rename
them to the domain naming method used by the script, and reselect them
in Opera's SSPs.
--
|
| Post Reply
|
|
|
|
|
|
|
|
|
|