This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions <= 12.15 and also provided by our OEX2NEX shim library.
For the latest Opera Extensions API documentation for Opera versions > 12.15 please consult the latest Opera Extensions API documentation online.
This method can be used to override global functions defined by regular scripts in a page.
name
: String giving the name of the function to be overridden.implementation
: Function to be run in place of the function defined by the page. The function will be passed the following parameters.
void defineMagicFunction (<DOMString> name, <Function> implementation)
window.opera.defineMagicFunction('getLayer', function (oRealFunc, oThis, oParam1, oParam2) {
return oParam1.getElementById(oParam2).style;
});
// This example overrides a function f. If the this object refers to the window object, it returns false.
// Otherwise it just runs the real function instead:
window.opera.defineMagicFunction('f', function (real, thisObject) {
if (thisObject == window) {
return false;
} else {
return real.apply(thisObject, Array.prototype.slice.call(arguments, 2));
}
});