Created
July 4, 2010 04:27
-
-
Save Sakurina/463126 to your computer and use it in GitHub Desktop.
shreds redundant selector declarations (cycript optimization)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# selache - by Yanik Magnan (r-ch.net) | |
# make selectors only appear in your cycript code ONCE | |
input_code = STDIN.read | |
selectors = input_code.scan(Regexp.new('(new)( )(Selector)(\\()(".*?")(\\))', Regexp::IGNORECASE)).uniq | |
sel_counter = 0; | |
selectors.each { |sel| | |
method_name = sel[4].gsub("\"","") | |
print "SEL#{sel_counter} = new Selector(\"#{method_name}\");" | |
input_code.gsub!("new Selector(\"#{method_name}\")", "SEL#{sel_counter}") | |
sel_counter += 1 | |
} | |
puts input_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment