Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var noun_type_color = new CmdUtils.NounType( "color", ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "purple", "red", "silver", "teal", "white", "yellow"], "yellow" )
- CmdUtils.CreateCommand({
- name: "high",
- author: {name:"Fernando Takai"},
- license:"GPL",
- icon: "chrome://ubiquity/skin/icons/textfield_rename.png",
- description: "Highlights with one of the 12 valid W3C colors!",
- takes: {"color": noun_type_color},
- preview: function( pblock, input) {
- var color = (input.text ? input.text : "yellow");
- pblock.innerHTML = "Highlights with this <span style='background-color:" + color + "'>color</span>"
- },
- execute: function(input) {
- var sel = context.focusedWindow.getSelection();
- var document = context.focusedWindow.document;
- if (sel.rangeCount >= 1) {
- var range = sel.getRangeAt(0);
- var newNode = document.createElement("span");
- newNode.style.background = (input.text ? input.text : "yellow");
- range.surroundContents(newNode);
- }
- }
- });
Add Comment
Please, Sign In to add comment