├── README.md └── Remove All Disabled Styles.sketchplugin └── Contents └── Sketch ├── manifest.json └── script.js /README.md: -------------------------------------------------------------------------------- 1 | # Remove All Disabled Styles 🚮 2 | 3 | A simple plugin that removes all disabled styles from all layers in the current selection. Useful to clean up your document from stray styles. Does not remove enabled styles (only the styles with a [ ] ) 4 | 5 | ## How to install 6 | 7 | 1. [Download the plugin](https://github.com/erikfontanel/sketch-remove-all-disabled-styles/archive/master.zip) 8 | 2. Double click on the `Remove All Disabled Styles.sketchplugin` file 9 | 10 | ## How to use 11 | 1. Select a or multiple layers 12 | 2. Select Remove All Disabled Styles from the Plugins menu 13 | 3. All disabled styles are removed from your selected layers 14 | 15 | 16 | ## To do 17 | 1. Abstract code to be more future proof if new layer styles are added to Sketch 18 | 2. Add options to remove all disabled styles on current page/current document 19 | -------------------------------------------------------------------------------- /Remove All Disabled Styles.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Remove All Disabled Styles", 3 | "identifier": "com.sketchapp.removealldisabledstyles", 4 | "version": "1.0", 5 | "description": "Removes all disabled styles from the selected layers", 6 | "author": "Erik Gelderblom", 7 | "updateURL": "https://github.com/erikfontanel/sketch-remove-all-disabled-styles/removealldisabledstyles.json", 8 | "commands": [{ 9 | "script": "script.js", 10 | "handler": "removeAllDisabledStyles", 11 | "shortcut": "", 12 | "name": "Remove All Disabled Styles", 13 | "identifier": "removealldisabledstyles" 14 | }] 15 | } 16 | -------------------------------------------------------------------------------- /Remove All Disabled Styles.sketchplugin/Contents/Sketch/script.js: -------------------------------------------------------------------------------- 1 | function removeAllDisabledStyles(context) { 2 | var doc = context.document 3 | var selection = context.selection 4 | 5 | var loop = selection.objectEnumerator() 6 | while (item = loop.nextObject()) { 7 | var fills = item.style().fills() 8 | var fills = fills.objectEnumerator() 9 | var fillIndex = 0; 10 | while (fill = fills.nextObject()) { 11 | if (!fill.isEnabled()) { 12 | item.style().removeStyleFillAtIndex(fillIndex) 13 | } 14 | fillIndex++ 15 | } 16 | 17 | var borders = item.style().borders() 18 | var borders = borders.objectEnumerator() 19 | var borderIndex = 0; 20 | while (border = borders.nextObject()) { 21 | if (!border.isEnabled()) { 22 | item.style().removeStyleBorderAtIndex(borderIndex) 23 | } 24 | borderIndex++ 25 | } 26 | 27 | var shadows = item.style().shadows() 28 | var shadows = shadows.objectEnumerator() 29 | var shadowIndex = 0; 30 | while (shadow = shadows.nextObject()) { 31 | if (!shadow.isEnabled()) { 32 | item.style().removeStyleShadowAtIndex(shadowIndex) 33 | } 34 | shadowIndex++ 35 | } 36 | 37 | var innerShadows = item.style().innerShadows() 38 | var innerShadows = innerShadows.objectEnumerator() 39 | var innerShadowIndex = 0; 40 | while (innerShadow = innerShadows.nextObject()) { 41 | if (!innerShadow.isEnabled()) { 42 | item.style().removeStyleInnerShadowAtIndex(innerShadowIndex) 43 | } 44 | innerShadowIndex++ 45 | } 46 | } 47 | 48 | // Refresh UI 49 | doc.currentPage().deselectAllLayers() 50 | selectionCount = selection.count() 51 | for (var i = 0; i < selection.count(); i++) { 52 | var layer = selection.objectAtIndex(i) 53 | layer.select_byExpandingSelection(true, true); 54 | } 55 | } 56 | --------------------------------------------------------------------------------