WME MultiActionHack

Library to replace MultiAction in WME

Fra og med 12.03.2025. Se den nyeste version.

Dette script bør ikke installeres direkte. Det er et bibliotek, som andre scripts kan inkludere med metadirektivet // @require https://update.greasyforks.org/scripts/529634/1552315/WME%20MultiActionHack.js

this.WS=this.WS||{},this.WS.SDKMultiActionHack=function(){"use strict";function n(){return"unsafeWindow"in window?window.unsafeWindow:window}class t{constructor(n,t,i){this._target=n,this._methodName=t,this._interceptor=i,this._isEnabled=!1,this.managedInterceptor=(...n)=>this._isEnabled?this._interceptor(((...n)=>this.invokeOriginal(...n)),...n):this.invokeOriginal(...n),this.initialize()}initialize(){this._originalMethod=this._target[this._methodName],this._target[this._methodName]=this.managedInterceptor}invokeOriginal(...n){return this._originalMethod.apply(this._target,n)}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}}function i(t){const i=function(){try{return n().require("Waze/Action/MultiAction")}catch(n){return null}}();if(!i)throw new Error("Unable to retrieve MultiAction");return new i(t)}class a{constructor(n){this._actionManager=n,this._actionsInTransaction=[],this._undoableActionsInTransaction=[],this._hasActiveTransaction=!1,this._interceptor=new t(n,"add",((i,a)=>{if(!this.isTransactionOpen)return i(a);if(a.undoSupported()){let i,o=!1;new t(a,"doAction",((n,...t)=>o?i:(o=!0,i=n(...t)))).enable(),new t(a,"undoAction",((n,...t)=>{const a=n(...t);return o=!1,i=void 0,a})).enable(),a.doAction(n.dataModel),this._undoableActionsInTransaction.push(a)}return this._actionsInTransaction.push(a),!0})),this._interceptor.enable()}closeTransaction(){return this._hasActiveTransaction=!1,this.getTransactionActions()}openTransaction(){this._actionsInTransaction=[],this._undoableActionsInTransaction=[],this._hasActiveTransaction=!0}get isTransactionOpen(){return this._hasActiveTransaction}beginTransaction(){this.openTransaction()}getTransactionActions(){return this._actionsInTransaction}commitTransaction(n){const t=this.closeTransaction(),a=i(t);a?(n&&(a._description=n),this._interceptor.invokeOriginal(a)):t.forEach((n=>this._interceptor.invokeOriginal(n)))}cancelTransaction(){this._undoableActionsInTransaction.forEach((n=>n.undoAction(this._actionManager.dataModel))),this.closeTransaction()}}const o=n();let s;return o.SDK_INITIALIZED.then((()=>{s=new a(o.W.model.actionManager)})),{beginTransaction:()=>s.beginTransaction(),commitTransaction:n=>s.commitTransaction(n),cancelTransaction:()=>s.cancelTransaction(),groupActions(n,t){s.beginTransaction();try{n(),s.commitTransaction(t)}catch(n){throw s.cancelTransaction(),n}}}}();
长期地址
遇到问题?请前往 GitHub 提 Issues。