From a140c3a3017a7d171d5b11d0495ba40fdac69e5d Mon Sep 17 00:00:00 2001 From: Mute Date: Thu, 7 Jul 2022 23:10:18 +0000 Subject: [PATCH] Update 'mbchc-local.user.js' --- mbchc-local.user.js | 51 ++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/mbchc-local.user.js b/mbchc-local.user.js index a6510fd..0fb2aa5 100644 --- a/mbchc-local.user.js +++ b/mbchc-local.user.js @@ -5,8 +5,8 @@ // @author codename.mute@proton.me // @namespace https://code.fleshless.org/mute/ // @homepage https://code.fleshless.org/mute/MBCHC -// @updateURL https://code.fleshless.org/mute/MBCHC/raw/branch/master/mbchc-dev.user.js -// @downloadURL https://code.fleshless.org/mute/MBCHC/raw/branch/master/mbchc-dev.user.js +// @updateURL https://code.fleshless.org/mute/MBCHC/raw/branch/master/mbchc-local.user.js +// @downloadURL https://code.fleshless.org/mute/MBCHC/raw/branch/master/mbchc-local.user.js // @match https://bondageprojects.elementfx.com/R* // @match https://www.bondageprojects.elementfx.com/R* // @match https://bondage-europe.com/R* @@ -19,8 +19,6 @@ /** @type {ModSDKGlobalAPI} */ // eslint-disable-next-line var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ERROR:\n"+o);const e=new Error(o);throw console.error(e),e}const t=new TextEncoder;function n(o){return!!o&&"object"==typeof o&&!Array.isArray(o)}function r(o){const e=new Set;return o.filter((o=>!e.has(o)&&e.add(o)))}const a=new Map,i=new Set;function d(o){i.has(o)||(i.add(o),console.warn(o))}function c(o,e){if(0===e.size)return o;let t=o.toString().replaceAll("\r\n","\n");for(const[n,r]of e.entries())t.includes(n)||d(`ModSDK: Patching ${o.name}: Patch ${n} not applied`),t=t.replaceAll(n,r);return(0,eval)(`(${t})`)}function s(o){const e=[],t=new Map,n=new Set;for(const r of u.values()){const a=r.patching.get(o.name);if(a){e.push(...a.hooks);for(const[e,i]of a.patches.entries())t.has(e)&&t.get(e)!==i&&d(`ModSDK: Mod '${r.name}' is patching function ${o.name} with same pattern that is already applied by different mod, but with different pattern:\nPattern:\n${e}\nPatch1:\n${t.get(e)||""}\nPatch2:\n${i}`),t.set(e,i),n.add(r.name)}}return e.sort(((o,e)=>e.priority-o.priority)),{hooks:e,patches:t,patchesSources:n,final:c(o.original,t)}}function l(o,e=!1){let r=a.get(o);if(r)e&&(r.precomputed=s(r));else{let e=window;const i=o.split(".");for(let t=0;t>>1:o>>>1;e=e>>>8^o}return((-1^e)>>>0).toString(16).padStart(8,"0").toUpperCase()}(d.toString().replaceAll("\r\n","\n")),l={name:o,original:d,originalHash:c};r=Object.assign(Object.assign({},l),{precomputed:s(l)}),a.set(o,r),e[i[i.length-1]]=function(o){return function(...e){const t=o.precomputed,n=t.hooks,r=t.final;let a=0;const i=d=>{var c,s,l,f;if(ao.mod))),patchedByMods:Array.from(t.precomputed.patchesSources)});return o}const u=new Map;function h(o){u.get(o.name)!==o&&e(`Failed to unload mod '${o.name}': Not registered`),u.delete(o.name),o.loaded=!1}function g(o,t,r){"string"==typeof o&&o||e("Failed to register mod: Expected non-empty name string, got "+typeof o),"string"!=typeof t&&e(`Failed to register mod '${o}': Expected version string, got ${typeof t}`),r=!0===r;const a=u.get(o);a&&(a.allowReplace&&r||e(`Refusing to load mod '${o}': it is already loaded and doesn't allow being replaced.\nWas the mod loaded multiple times?`),h(a));const i=t=>{"string"==typeof t&&t||e(`Mod '${o}' failed to patch a function: Expected function name string, got ${typeof t}`);let n=c.patching.get(t);return n||(n={hooks:[],patches:new Map},c.patching.set(t,n)),n},d={unload:()=>h(c),hookFunction:(t,n,r)=>{c.loaded||e(`Mod '${c.name}' attempted to call SDK function after being unloaded`);const a=i(t);"number"!=typeof n&&e(`Mod '${o}' failed to hook function '${t}': Expected priority number, got ${typeof n}`),"function"!=typeof r&&e(`Mod '${o}' failed to hook function '${t}': Expected hook function, got ${typeof r}`);const d={mod:c.name,priority:n,hook:r};return a.hooks.push(d),f(),()=>{const o=a.hooks.indexOf(d);o>=0&&(a.hooks.splice(o,1),f())}},patchFunction:(t,r)=>{c.loaded||e(`Mod '${c.name}' attempted to call SDK function after being unloaded`);const a=i(t);n(r)||e(`Mod '${o}' failed to patch function '${t}': Expected patches object, got ${typeof r}`);for(const[n,i]of Object.entries(r))"string"==typeof i?a.patches.set(n,i):null===i?a.patches.delete(n):e(`Mod '${o}' failed to patch function '${t}': Invalid format of patch '${n}'`);f()},removePatches:o=>{c.loaded||e(`Mod '${c.name}' attempted to call SDK function after being unloaded`);i(o).patches.clear(),f()},callOriginal:(t,n,r)=>(c.loaded||e(`Mod '${c.name}' attempted to call SDK function after being unloaded`),"string"==typeof t&&t||e(`Mod '${o}' failed to call a function: Expected function name string, got ${typeof t}`),Array.isArray(n)||e(`Mod '${o}' failed to call a function: Expected args array, got ${typeof n}`),function(o,e,t=window){return l(o).original.apply(t,e)}(t,n,r)),getOriginalHash:t=>("string"==typeof t&&t||e(`Mod '${o}' failed to get hash: Expected function name string, got ${typeof t}`),l(t).originalHash)},c={name:o,version:t,allowReplace:r,api:d,loaded:!0,patching:new Map};return u.set(o,c),Object.freeze(d)}function m(){const o=[];for(const e of u.values())o.push({name:e.name,version:e.version});return o}let w;const y=void 0===window.bcModSdk?window.bcModSdk=function(){const e={version:o,apiVersion:1,registerMod:g,getModsInfo:m,getPatchingInfo:p,errorReporterHooks:Object.seal({hookEnter:null,hookChainExit:null})};return w=e,Object.freeze(e)}():(n(window.bcModSdk)||e("Failed to init Mod SDK: Name already in use"),1!==window.bcModSdk.apiVersion&&e(`Failed to init Mod SDK: Different version already loaded ('1.0.2' vs '${window.bcModSdk.version}')`),window.bcModSdk.version!==o&&alert(`Mod SDK warning: Loading different but compatible versions ('1.0.2' vs '${window.bcModSdk.version}')\nOne of mods you are using is using an old version of SDK. It will work for now but please inform author to update`),window.bcModSdk);return"undefined"!=typeof exports&&(Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=y),y}(); -// FIXME read chars as they enter -// TODO BCE emotes detector -> activities (function() { "use strict"; if (!window.AsylumGGTSSAddItems) throw "AsylumGGTSSAddItems() not found, aborting MBCHC loading" @@ -103,7 +101,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER VulvaPiercings: {all: "SpankItem|TickleItem|RubItem|MasturbateItem|ShockItem|Inject"}, }, "kiss": { - Mouth: {others: "Kiss|GagKiss|GaggedKiss"}, + Mouth: {others: "GagKiss|Kiss|GaggedKiss"}, "Boots,Hands": {self: "PoliteKiss", others: "PoliteKiss|GaggedKiss"}, "Arms,Breast,Nipples": {self: "Kiss", others: "Kiss|GaggedKiss"}, "Butt,Ears,Feet,Head,Legs,Neck,Nose,Pelvis,Torso,Vulva,VulvaPiercings": {others: "Kiss|GaggedKiss"} @@ -148,7 +146,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER "ItemMouth": ["mouth", "lip", "lips", "teeth", "tongue", "gag", "cheek", "cheeks"], "ItemNose": ["nose", "nostrils"], "ItemEars": ["ear", "ears", "earlobe", "earlobes"], - "ItemHead": ["head", "face", "hair", "eyes"], + "ItemHead": ["head", "face", "hair", "eyes", "forehead"], }, USAGE_MBCHC_LINES: [ "
Usage: /mbchc SUBCOMMAND [ARGS...]
", @@ -230,9 +228,8 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER char.FocusGroup = this.ensure("invalid AssetGroup", () => window.AssetGroupGet(char.AssetFamily, ag)) let activity = this.ensure("invalid activity", () => window.ActivityAllowedForGroup(char, char.FocusGroup.Name, true).find( a => a.Name === action)) if (activity.Name.endsWith("Item")) { - var dict = [{Tag: "NextAsset", AssetName: "SpankingToys"}, {Tag: "FocusAssetGroup", AssetGroupName: ag}, {Tag: "SourceCharacter", Text: window.CharacterNickname(window.Player), MemberNumber: window.Player.MemberNumber}] - dict.push({Tag: "DestinationCharacter", Text: window.CharacterNickname(char), MemberNumber: char.MemberNumber}) - window.ServerSend("ChatRoomChat", {Type: "Action", Content: `ActionActivity${activity.Name}`, Dictionary: dict}) + let item = this.ensure("no toy found", () => window.Player.Inventory.find(i => (i.Asset != null) && (i.Asset.Group.Name == char.FocusGroup.Name) && i.Asset.DynamicAllowInventoryAdd(char))) + window.DialogItemClick(window.DialogInventoryCreateItem(char, item, false)) } else { window.ActivityRun(char, activity) } @@ -277,17 +274,14 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER item.Property = {Type: "Hair", Hide: this.HIDE_ALL} window.CharacterRefresh(window.Player, true, true) }, - title: function(args) { + title: function(args) { // WIP let title = args.shift() if (this.empty(title)) throw "empty title" title = this.normalise_message(title, {trim: true, up: true, low: true}) if (title.length > 16) throw "title too long" if (!title.match(this.RE_TITLE)) throw "invalid title" window.TitleSet(title) - // TODO: this needs much more work. at least don't push a second title - // we need to patch the text cache - // we need to check for other players' custom titles - //window.TitleList.push({Name: title, Requirement: () => {return true}}) + //window.TitleList.push({Name: title, Requirement: () => {return true}}) // check for existing first }, patch_handheld: function() { let options = InventoryItemHandsSpankingToysOptions /* eslint-disable-line no-undef */ // window.InventoryItemHandsSpankingToysOptions is undefined @@ -319,23 +313,14 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER if (match) return(Number.parseInt(match[1])) return(null) }, - player_enters_room: function() { // FIXME: Description may not be ready yet + player_enters_room: function() { this.hello() - for (let i in window.ChatRoomCharacter) { - let char = window.ChatRoomCharacter[i] - if (!char.MBCHC_LOCAL) char.MBCHC_LOCAL = {} - if (!char.MBCHC_LOCAL.TZ) { - let tz = this.find_timezone(char) - if (tz) char.MBCHC_LOCAL.TZ = tz - } - } }, set_timezone: function(args) { - let char = this.ensure("invalid target", ()=> this.id2char(args[0])) + let char = this.ensure("invalid target", () => this.id2char(args[0])) let tz = Number.parseInt(args[1]) if (isNaN(tz)) throw "invalid offset" if ((tz < -12) || (tz > 12)) throw "offset should be [-12,12]" - if (!char.MBCHC_LOCAL) char.MBCHC_LOCAL = {} char.MBCHC_LOCAL.TZ = tz this.save_settings((s) => { if (!s.timezones) s.timezones = {}; s.timezones[char.MemberNumber] = tz }) }, @@ -371,7 +356,6 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER this.send_activity(message) } catch (x) { this.report(x) } } }, command_do: function(argline, cmdline, args) { try { - // FIXME arousal for items if (args.length < 1) return(this.inform("
Usage: /do VERB [ZONE] [TARGET]
Available verbs:
" + Object.keys(this.MAP_ACTIONS).join(", ") + "
Available zones:
" + Object.keys(this.DO_DATA.zones).join(", "))) let [verb, zone, target] = args if (!this.DO_DATA.verbs[verb]) throw `unknown verb "${verb}"` @@ -394,7 +378,11 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER this.run_activity(char, ag, action) } catch (x) { this.report(x) } }, loader: function() { - if (this.LOADED) return //FIXME: unhook if hooked, no need to call this every time + if (this.remove_load_hook) { + this.remove_load_hook() + delete this.remove_load_hook + } + if (this.LOADED) return // Calculated values this.HIDE_ALL = this.HIDE_SPECIAL.concat(this.HIDE_BODY).concat(this.HIDE_CLOTHES).concat(this.HIDE_ITEMS) this.CommandsKey = CommandsKey /* eslint-disable-line no-undef */ // window.CommandsKey is undefined @@ -412,6 +400,13 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER // Hooks window.MBCHC.sdk = window.bcModSdk.registerMod("MBCHC", window.MBCHC.VERSION) + window.MBCHC.sdk.hookFunction("CharacterOnlineRefresh", 0, (args, next) => { + let result = next(args) + let char = args[0] + if (!char.MBCHC_LOCAL) char.MBCHC_LOCAL = {} + if (!char.MBCHC_LOCAL.TZ) char.MBCHC_LOCAL.TZ = window.MBCHC.find_timezone(char) + return(result) + }) window.MBCHC.sdk.hookFunction("ChatRoomMessageInvolvesPlayer", 0, (args, next) => { let data = args[0] if (!data.MBCHC_ID) { @@ -458,7 +453,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER // MAIN SCREEN TURN ON if (window.MBCHC.need_load_hook(window.CurrentModule, window.CurrentScreen)) { - window.MBCHC.sdk.hookFunction("AsylumGGTSSAddItems", 0, (args, next) => { window.MBCHC.loader(); return(next(args)) }) + window.MBCHC.remove_load_hook = window.MBCHC.sdk.hookFunction("AsylumGGTSSAddItems", 0, (args, next) => { window.MBCHC.loader(); return(next(args)) }) } else { window.MBCHC.loader() if(("Online" === window.CurrentModule) && ("ChatRoom" === window.CurrentScreen)) window.MBCHC.player_enters_room()