I have to imagine that there is a good reason (maybe specific to doing it through the registry) that they duplicated the same commands a few times for both "all objects" and "exe" and "dll" files specifically... and then a slightly different command line needed for recursing through directories. But I don't think you need to do the same for adapting it to run from Opus.
So, here are two Opus button definitions... one for files, and the other for folders. You can paste these definitions directly to any toolbar and just use these commands as buttons - or after doing so just to get a look at the commands inside the buttons, you can then use the commands in your own context menu entries. The command for "files" would be added to the "All files" category in the Opus File Types editor, while the command for "folders" would naturally be added to the "All folders" category.
Files:
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>Take Ownership (Files)</label>
<icon1>#adminmode</icon1>
<function type="batch">
<instruction>cmd.exe /c takeown /f {f} && icacls {f} /grant administrators:F</instruction>
<instruction>pause</instruction>
</function>
</button>
Folders:
<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none">
<label>Take Ownership (Folders)</label>
<icon1>#adminmode</icon1>
<function type="batch">
<instruction>cmd.exe /c takeown /f {f} /r /d y && icacls {f} /grant administrators:F /t</instruction>
<instruction>pause</instruction>
</function>
</button>