Not sure how you will be doing the op'ing, so I'm using ChanServ in this example.
This script might cause you to disconnect due to flooding depending on the network settings / how many channels you are in.
; This will deop me on every channel if I am op.
; Syntax: /deopme
alias deopme {
var %x $chan(0)
while (%x) {
if ($me isop $chan(%x)) {
mode $chan(%x) -o $me
dec %x
}
else {
dec %x
}
}
}
; This will op me on every channel if I am not op.
; Syntax: /opme
alias opme {
var %x $chan(0)
while (%x) {
if ($me !isop $chan(%x)) {
msg ChanServ op $chan(%x) $me
dec %x
}
else {
dec %x
}
}
}