Skip to content

Instantly share code, notes, and snippets.

@Sakurina
Created July 4, 2010 04:27
Show Gist options
  • Save Sakurina/463126 to your computer and use it in GitHub Desktop.
Save Sakurina/463126 to your computer and use it in GitHub Desktop.
shreds redundant selector declarations (cycript optimization)
#!/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