Useful Extensions, Keys, Scripts, CSS, etc for Stylish
From the beginning, I started this thread because I wanted to share two awesome key scripts I'd found. Now I've expanded my idea:
Here is a thread for sharing, requesting, suggesting and improving anything about useful Extensions, Keys, Scripts, CSS, etc. for Stylish.
I'll try to keep a list of all the best at the top.
Extensions
Must-have extensions.
Keys
Keyboard shortcuts to be used in the Stylish editor, via keyconfig by dorando. Edit any style, then open keyconfig. In the box at the top, choose the entry with the name of the style you currently edit. Press "Add a new key", paste some code from below, and assign a shortcut for it. That's it, now the key will be available when editing any style.
All these scripts work in the Scratchpad, too, if you use Orion (set devtools.editor.component to orion in about:config). In each Scratchpad window you must run an "init" script once first, though.
Here is a thread for sharing, requesting, suggesting and improving anything about useful Extensions, Keys, Scripts, CSS, etc. for Stylish.
I'll try to keep a list of all the best at the top.
Extensions
Must-have extensions.
- Stylish-Custom (SC) by ChoGGi
An enhancement suite for Stylish, with way to many features to list them. It could replace/be replaced by many of the things below. Discussion and suggestions for it goes here. - DOM Inspector by Colby Russel, SeaMonkey Council and contributors
Inspect elements, to get selectors, already applied style, computed style etc. - InspectorWidget by Sailfish
Extends DOM Inspector. Easier inscpecting via a toolbar button. (Can be replaced by the Custom Button DOM Inspector.) - Inspect Context by max1million
Extends DOM Inspector. Easier inscpecting via a context menu item. (Can be replaced by the Custom Button DOM Inspector.)
Keys
Keyboard shortcuts to be used in the Stylish editor, via keyconfig by dorando. Edit any style, then open keyconfig. In the box at the top, choose the entry with the name of the style you currently edit. Press "Add a new key", paste some code from below, and assign a shortcut for it. That's it, now the key will be available when editing any style.
All these scripts work in the Scratchpad, too, if you use Orion (set devtools.editor.component to orion in about:config). In each Scratchpad window you must run an "init" script once first, though.
- Preview by LouCypher (from here)
(Included in SC.)preview();
- Edit in external editor by LouCypher
Get the code from here. - Insert text at start by LouCypher
insertCodeAtStart("YOURTEXTHERE");
Here's some useful cases:- Insert HTML namespace at start by LouCypher
insertCodeAtStart(CSSHTMLNS);
- Insert XUL namespace at start by LouCypher
insertCodeAtStart(CSSXULNS);
- Insert HTML namespace at start by LouCypher
- Insert text at caret
To insert, for example, !important;. (Included in SC.) - Insert text at caret - Choose from a menu by banthaz
This key brings up a prompt box, where you can choose piece of text to insert from a list. You can change the list of available text pieces at the beginning of the code, like this: [, , ]. If [1] () is left undefined, [0] () is displayed instead. [2] () should normally be left undefined. If not, the script will see [0] () as a function to be run (using eval()).
(A similar, though less advanced, feature is included in SC.)
Get the code from here.As one of the examples in the list of text to insert in the code, I've included:- Insert Data URI by LouCypher
insertDataURI();
- Insert Data URI by LouCypher
- Comment/Uncomment code Enhanced by Zoolcar9 and Morgan B (from here) and banthaz
Short version: Comments selected code, uncomments selected comments. Long version: here.
(Similar features are included in SC.)
Get the code from here. - Go to line by banthaz
Shows a prompt box that tells you which line you're currently on and lets type in the line you want to go to. (A similar feature is included in SC.)
Get the code from here.Note: If you want to use this in the Scratchpad, you must replace the last line with this:var index = 0;
for (var i = 1; i < line; i++) index = textbox.value.indexOf("\n", index) + 1;
textbox.setSelectionRange(index, index); - Replace Enhanced by banthaz
Both simple search and replace and some advanced modes. See more here.
(A similar, though less advanced, feature is included in SC.)
Get the code from here. - Insert "Headers" by banthaz
Inserts "Headers" of different lengths at caret. Lengths can be customized at the two fist lines of the code.
Get the code from here. - rgb()-hex converter by banthaz
Converts the selection if it is a valid rgb() or hex color.
Get the code from here. - Brackets by banthaz
Inserts a {, a new line with the same indentation as the previous line, one level of indentation (default is 4 spaces, but this can be changed at the first line of the code) and a }. It then moves the caret between the brackets. If some text is selected, that text will be put between the brackets, properly indented.
Get the code from here. - Select lines by banthaz
Selects the whole line where the caret currently is, including the ending new line character. If some text is selected, the start and end of the selection will be extended to the start/end of their respective lines.
Get the code from here.
Comments
Buttons to install via Custom Buttons by Yan, cubegm and SCClockDr.
Extends DOM Inspector. Old version of InspectorWidget, new version of InspectorWidget and Inspect Context combined - into a single button!
Commands
Here are commands (or scripts) that can be used via extensions such as keyconfig by dorando, Custom Buttons by Yan, cubegm and SCClockDr and FireGestures by Gomita or other use.
userChrome.js
Scripts that extend Stylish in some way, added via extensions such as userChromeJS by mozdev.org and Custom Buttons by Yan, cubegm and SCClockDr.
With userChromeJS, simply add code into the userChrome.js file.
With Custom Buttons, add code into some button's init tab. Tip: Create a button only for this "userChrome.js replacement" purpose. Add custombuttons.editButton(this); to the button's code tab. Then your userChrome.js replacement is always only one click away!
CSS tweaks
Small CSS codes.
(Similar feature is included in SC.)
This makes Stylish's sorting buttons more compact, like the rest of the sorting buttons in the Add-ons Manager.
Userstyles
Userstyles.
(Similar feature is included in SC, ie full customization of the toolbars and a toggle button etc.)
More:
Yes, it's not a shortcut but you seem to be reinventing a wheel with all those js when all this is already available in SC in form of simple button click.
Thanks, LouCypher!
I used SC in the past, but I had many problems with it (and I didn't feel like investigating and reporting them) and it added way more features than I needed. So I try to replace SC using other ways, like CSS and keyconfig. And I don't like buttons when editing, it's too slow. But thanks for mentioning it, though!
Code for Insert text at caret - Choose from a menu:
Code for Go to line:
Detailed description for Replace Enhanced:
First off: At the second line of the code, the variable m is defined. It's a string used for many things throughout the script. m = ´ by default. You can of course change this. This script also assumes that you never put a nul character (\0) in your code. If you do, this can be changed at the third line in the code.
It has two search modes: Normal and RegExp. In Normal mode, it will search for exactly what you've typed. By starting the search term with a slash (/), and ending with a slash (/) + any valid modifiers, RegExp mode is turned on. If you want to start with a slash (/) without turning on RegExp mode, type /m (m being that special string, remember?).
In Normal search mode, the modifiers (flags) for the search are gi, which means that it will find all matches, and that it is case insensitive. This can be changed at the first line in the code.
In Normal search and replace mode, \n is treated as a new line character, and \t as a tab. You can escape this using by typing \mn and \mt respectively. In fact, in normal search and replace mode, all occurrences of m, except mm, are automatically removed. This means that you have to type mm to search for m in these modes. I advice you to set m to something that you never, or rarely, use in your code, but still is easy enough to type from the keyboard.
By starting the search term with m, all the matches (if any) will be displayed. The result is displayed as a literal array ([match1,match2,match3,...]). If possible, matches will be converted into numbers. Otherwise they'll be properly escaped to be a string. [i] is added afterwards. The reason for all this is explained later.
In normal replace mode, you can use $$, $&, $`, $', $1, $2, $3 etc. as usual. Moreover, $0 acts as $&.
By starting the replace term with m, each match will be replaced by the return value of the function you type. The i variable starts at 0 at the first match and then increases by 1 per each match, if you need such a variable. The $0, $1, $2, $3 etc. variables work as in Normal replace mode, plus that they are automatically converted into numbers if possible. The $0o variable is the current offset and the $ variable is the total string. All occurrences of m, except mm, are automatically replaced with return . So instead of writing return $1+1, you could simply write m$1+1. This means that you have to type mm to get a m in this mode.
An example (using m=´):
Lets say you have the following code: Now you want to increase all the font-size:s by 1px, but not change the px values in the quotes. In such a small piece of code it's of course easy to do it by hand, but let's say this is just one of hundreds of similar code pieces.
´ --> the matches will be displayed
Note: It will be treated as a RegExp.
Since there are no £:s in the code, we can use it.
Note: It will be treated as a RegExp.
´ --> the replace term will act as a function
´ --> the second m will be replaced by return
$1is a variable like $1 in Normal replace mode. That is already automatically converted into a number. +1 increases it by one. Then "px" is added back.
This demonstrates simple search mode. No RegExp.
This is an ´ + the displayed matches that we copied earlier.
´ --> the replace term will act as a function
´ --> the second m will be replaced by return
Since i increases by 1 per each match, a new match from the literal array will be chosen each time, effectively putting the quotes back.
Code for "init":
Code for Brackets:
Code for Select lines:
Detailed description for Comment/Uncomment code Enhanced:
Priorities:
UPDATES:
Optimized:
Improved:
Simplified. Non-execute/Insert list items can now have a custom text too.
Added:
(Press ctrl+f and search for <br /> to find them.)
UPDATES:
Optimized:
Improved:
Better scrolling.
Fixed:
Better scrolling.
You can now insert the text "\n" or "\t" (without getting it converted into a new line or tab character), by writing "\\n" or "\\t", respectively, which wasn't working before.
UPDATES:
Fixed:
Fixed for Firefox 8.
Note:
UPDATES:
Optimized:
Improved:
New advanced functions.
Fixed:
Now work with Orion.
Note:
UPDATES:
Optimized:
Improved:
Caret placed just before a /* -> Nearest */ to the right is found, and it will be uncommented.
Caret placed just after a */ -> Nearest /* to the left is found, and it will be uncommented.
Added:
UPDATES:
Fixed:
Minor bugs.
Several critical and minor bugs.
Improved:
Simplified, which makes it more stable and easy to use.
It now checks your RegExps and executed replace terms for errors.
UPDATES:
Fixed:
If RegExp mode was used, using a executable replace term didn't work.
UPDATES:
Fixed:
One very minor bug.
Fixed many more or less minor bugs.
Replaced the complicated and buggy system of escaping characters.
UPDATES:
Fixed:
When displaying all matches, or when executing the replace term, the automatic string-to-number conversion didnt work for 0 (zero).
UPDATES:
Improved:
Lots of bugfixes, a lot of new features.
Lots of bugfixes, a lot simpler code, by now using the replace method more efficiently.
Please replace it with
https://loucypher.googlecode.com/svn/custombuttons/xml/DOM Inspector.xml
Yes?
I don't know.
keyconfig.
Man, I must correct the markup of my posts here some time. It's horrible! And, indeed, update my scripts - buggy and badly coded are what they are (even if they do their job somewhat well) ... well, that's what happens when you code as a beginner and run out of enthusiasm ...
Design is a suite of web-design and development assistive tools which can be utilised on any web-page. Encompassing utilities for grid layout, measurement and alignment, Design is a uniquely powerful JavaScript bookmarklet.
▷ Design features the following components:
- Grid - overlays a highly configurable layout grid over a web-page. Grid can be set to match any set of dimensions, allowing easy development of CSS layouts in the web-browser.
- Rule - displays rulers on a page, with all the expected features of the rulers found in a desktop design application, including guides which snap to block display elements and origin location control.
- Unit - allows measurements to be made between any two points on a web-page, giving basic information about each of the points clicked on, and drawing a line on the page for the measurement.
- Crosshair - draws a crosshair cursor on the page to assist in layout alignment. Cursor information is also presented in a tooltip.
CSS3 Drop Shadows Generator
"better replacement for DomInspector, allows viewing dom structure of any open document (most useful for xul); xbl bindings, event listeners and css rules for any node ability to search through all the css rules in document ability to search nodes in document using xpath.
Principal key (that i try):
- F1 : open it (with tooltip for keys usable)
- Mum7 : Open its DOM inspector
Found by mikedl : in [Bug] DOMi "Search By Id" is broken:
FoxiMirror: aka Shadia The Light Inspector
Animatable One property, two values, endless possiblities
And This (https://developer.mozilla.org/) lists all CSS properties and indicates if and how they are animatable.
CSS animated properties
Animate.css, a bunch of cool, fun, and cross-browser animations for you to use in your projects.
- Replacing icons with font glyphs for design elements?
- Suggestion: allow @import from Google Web Fonts in styles hosted on userstyles.org
- How to use @font-face (to add a special ICON) with Userstyles ?
- Replacing icons with font glyphs for design elements?
- question about data:image/png;base64
A Solution ?? : FREE Fonts with support for much of the unicode standard ,(nearly the Arial Unicode MS which is only installed by a Microsoft program) :
Code2000 (Wikipedia)
fonts2u : Code2000 font
fonts2u : Code2002 font
fonts2u : Code2001 font
Remember you can use SVG, even without base64.
body:before { content: url('data:image/svg+xml,\ <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40">\ <style>circle,path{stroke-width:5;stroke:rgb(30,30,30);stroke-linecap:round;fill:none}<\/style>\ <circle r="5" cx="15" cy="10" />\ <circle r="5" cx="25" cy="10" />\ <path d="m5,15 a 15 15 0 0 0 30 0"/></svg>\ ') 'Weee!' }