Skip to content

Instantly share code, notes, and snippets.

@sinak
Forked from sweatpantsninja/gist:5400379
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinak/0050ae57d02df85f3503 to your computer and use it in GitHub Desktop.
Save sinak/0050ae57d02df85f3503 to your computer and use it in GitHub Desktop.
if 'createTouch' of document
ignore = /:hover\b/
try
for stylesheet in document.styleSheets
idxsToDelete = []
# detect hover rules
for rule, idx in stylesheet.cssRules
if rule.type is CSSRule.STYLE_RULE and ignore.test(rule.selectorText)
newSelector = _.reject rule.selectorText.split(","), (s) -> ignore.test s
if newSelector.length > 0
newRule = newSelector.join(",").concat rule.cssText.substr(rule.cssText.indexOf("{"))
stylesheet.deleteRule idx
stylesheet.insertRule newRule, idx
else
idxsToDelete.unshift idx
# delete hover rules
stylesheet.deleteRule idx for idx in idxsToDelete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment