// ==UserScript==
// @name 猫国建设者挂机插件
// @namespace https://github.com/jiang-ruo/moescript
// @description 游戏《猫国建设者/喵国建设者/Kittens Game》网页自动化插件(就是外挂),可以在页面->选项->MoeScript中开启/关闭自动化功能
// @version 0.14.5
// @author jiang
// @author visnz
// @match https://likexia.gitee.io/cat-zh/*
// @match https://zhaolinxu.github.io/cat-zh/*
// @grant GM_addStyle
// @license GPL-3.0
//
// ==/UserScript==
//
// 因为使用了中文作为函数名,在脚本这边只使用经过优化处理的js代码。
// 源码可以直接访问上方 @namespace 地址
// frok from: https://github.com/visnz/moescript
// 基于@visnz的版本进行了二开,做一些符合个人喜好的改动,以及适配新的网址
//
// 下面是声明变量:
// $ - jquery的简写 - 页面自带jquery,不知道原作者为什么要引入,这里将@require中的jquery移除,使用页面中的jquery
// gamePage - 页面中自带的gamePage对象
/* global $ */
/* global gamePage */
var __defProp = Object.defineProperty;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var _ratio, _ratio2, _to;
const RESOURCE_INITIAL_INFO = [
{ "name": "catnip", "title": "猫薄荷", "type": "common" },
{ "name": "wood", "title": "木材", "type": "common" },
{ "name": "minerals", "title": "矿物", "type": "common" },
{ "name": "coal", "title": "煤", "type": "common" },
{ "name": "iron", "title": "铁", "type": "common" },
{ "name": "titanium", "title": "钛", "type": "common" },
{ "name": "gold", "title": "黄金", "type": "common" },
{ "name": "oil", "title": "石油", "type": "common" },
{ "name": "uranium", "title": "铀", "type": "common" },
{ "name": "unobtainium", "title": "难得素", "type": "common" },
{ "name": "antimatter", "title": "反物质", "type": "common" },
{ "name": "manpower", "title": "喵力", "type": "common" },
{ "name": "science", "title": "科学", "type": "common" },
{ "name": "culture", "title": "文化", "type": "common" },
{ "name": "faith", "title": "信仰", "type": "common" },
{ "name": "kittens", "title": "猫口", "type": "common" },
{ "name": "zebras", "title": "斑马", "type": "common" },
{ "name": "starchart", "title": "星图", "type": "common" },
{ "name": "temporalFlux", "title": "时间通量", "type": "common" },
{ "name": "gflops", "title": "浮点", "type": "common" },
{ "name": "hashrates", "title": "哈希率", "type": "common" },
{ "name": "furs", "title": "毛皮", "type": "uncommon" },
{ "name": "ivory", "title": "象牙", "type": "uncommon" },
{ "name": "spice", "title": "香料", "type": "uncommon" },
{ "name": "unicorns", "title": "独角兽", "type": "rare" },
{ "name": "alicorn", "title": "天角兽", "type": "rare" },
{ "name": "necrocorn", "title": "死灵兽", "type": "rare" },
{ "name": "tears", "title": "眼泪", "type": "rare" },
{ "name": "karma", "title": "业", "type": "rare" },
{ "name": "paragon", "title": "领导力", "type": "common" },
{ "name": "burnedParagon", "title": "燃烧领导力", "type": "common" },
{ "name": "timeCrystal", "title": "时间水晶", "type": "common" },
{ "name": "sorrow", "title": "悲伤", "type": "common" },
{ "name": "relic", "title": "遗物", "type": "exotic" },
{ "name": "void", "title": "虚空", "type": "exotic" },
{ "name": "elderBox", "title": "礼物盒", "type": "exotic" },
{ "name": "wrappingPaper", "title": "包装纸", "type": "exotic" },
{ "name": "blackcoin", "title": "黑币", "type": "exotic" },
{ "name": "bloodstone", "title": "血石", "type": "exotic" },
{ "name": "tMythril", "title": "T秘银", "type": "exotic" },
{ "name": "beam", "title": "木梁", "type": "common" },
{ "name": "slab", "title": "石板", "type": "common" },
{ "name": "plate", "title": "金属板", "type": "common" },
{ "name": "steel", "title": "钢", "type": "common" },
{ "name": "concrate", "title": "混凝土", "type": "common" },
{ "name": "gear", "title": "齿轮", "type": "common" },
{ "name": "alloy", "title": "合金", "type": "common" },
{ "name": "eludium", "title": "E合金", "type": "common" },
{ "name": "scaffold", "title": "脚手架", "type": "common" },
{ "name": "ship", "title": "船", "type": "common" },
{ "name": "tanker", "title": "油轮", "type": "common" },
{ "name": "kerosene", "title": "煤油", "type": "common" },
{ "name": "parchment", "title": "羊皮纸", "type": "common" },
{ "name": "manuscript", "title": "手稿", "type": "common" },
{ "name": "compedium", "title": "概要", "type": "common" },
{ "name": "blueprint", "title": "蓝图", "type": "common" },
{ "name": "thorium", "title": "钍", "type": "common" },
{ "name": "megalith", "title": "巨石", "type": "common" }
];
const resourceMap = {};
for (const value of RESOURCE_INITIAL_INFO) {
resourceMap[value.title] = {
name: value.name,
title: value.title,
type: value.type,
class: `resource_${value.name}`
};
}
var GenerateType = /* @__PURE__ */ ((GenerateType2) => {
GenerateType2["GT1"] = "craft-1pc";
GenerateType2["GT5"] = "craft-5pc";
GenerateType2["GT10"] = "craft-10pc";
GenerateType2["GT_ALL"] = "all";
return GenerateType2;
})(GenerateType || {});
var operate;
((operate2) => {
function getResourceInfo(resource) {
const game = moe.game();
if (!game) return;
const base = resourceMap[resource];
if (!base) {
moe.log.console(`资源【${resource}】不存在`);
return;
}
const res = game.resPool.resourceMap[base.name];
if (!res) {
moe.log.console(`资源【${resource}】不存在`);
return;
}
return {
resource,
value: res.value,
maxValue: res.maxValue,
tickCached: res.perTickCached
};
}
operate2.getResourceInfo = getResourceInfo;
function getResourceRatio(resource) {
const ri = getResourceInfo(resource);
if (!ri) return NaN;
return ri.value / ri.maxValue;
}
operate2.getResourceRatio = getResourceRatio;
function generateResource(resource, type) {
const base = resourceMap[resource];
if (!base) {
moe.log.console(`资源【${resource}】不存在`);
return;
}
$(`div.craft.${base.class} .${type}`).click();
}
operate2.generateResource = generateResource;
function getActiveTab() {
return $(".activeTab").parent().children(".activeTab").index() + 1;
}
operate2.getActiveTab = getActiveTab;
function changeTab(tab) {
$(`a.tab:nth-child(${tab})`)[0].click();
}
operate2.changeTab = changeTab;
function 提拔小猫() {
const game = moe.game();
game == null ? void 0 : game.village.promoteKittens();
}
operate2.提拔小猫 = 提拔小猫;
((SpecialEnum2) => {
SpecialEnum2[SpecialEnum2["蜥蜴"] = 0] = "蜥蜴";
SpecialEnum2[SpecialEnum2["鲨鱼"] = 1] = "鲨鱼";
SpecialEnum2[SpecialEnum2["狮鹫"] = 2] = "狮鹫";
SpecialEnum2[SpecialEnum2["娜迦"] = 3] = "娜迦";
SpecialEnum2[SpecialEnum2["斑马"] = 4] = "斑马";
})(operate2.SpecialEnum || (operate2.SpecialEnum = {}));
function specialName(special) {
switch (special) {
case 0:
return "蜥蜴";
case 1:
return "鲨鱼";
case 2:
return "狮鹫";
case 3:
return "娜迦";
case 4:
return "斑马";
default:
throw new Error("未知的特殊种族");
}
}
operate2.specialName = specialName;
function trade(special) {
const game = moe.game();
game == null ? void 0 : game.diplomacy.trade(game.diplomacyTab.racePanels[special].race);
}
operate2.trade = trade;
function tradeAll(special) {
const game = moe.game();
game == null ? void 0 : game.diplomacy.tradeAll(game.diplomacyTab.racePanels[special].race);
}
operate2.tradeAll = tradeAll;
})(operate || (operate = {}));
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const options = {};
let verifyOptions = function() {
return true;
};
var option$a;
((option2) => {
const sec = (s) => s * 1e3;
const min = (m) => m * sec(60);
const hour = (h) => h * min(60);
((Period2) => {
Period2[Period2["S0立即执行"] = sec(0)] = "S0立即执行";
Period2[Period2["S5秒"] = sec(5)] = "S5秒";
Period2[Period2["S15秒"] = sec(15)] = "S15秒";
Period2[Period2["S30秒"] = sec(30)] = "S30秒";
Period2[Period2["M1分钟"] = min(1)] = "M1分钟";
Period2[Period2["M5分钟"] = min(5)] = "M5分钟";
Period2[Period2["M10分钟"] = min(10)] = "M10分钟";
Period2[Period2["H1小时"] = hour(1)] = "H1小时";
})(option2.Period || (option2.Period = {}));
function regiterOption(option3) {
if (options[option3.flag]) {
verifyOptions = function() {
alert(`${moe.log.PREFIX}无法运行,因为定义了重复的缓存键: ${option3.flag}`);
return false;
};
} else {
options[option3.flag] = option3;
}
}
option2.regiterOption = regiterOption;
})(option$a || (option$a = {}));
let config;
function loadConfig() {
const configStr = localStorage.getItem(moe.STORAGE_KEY);
config = configStr ? JSON.parse(configStr) : {};
for (const key in config) {
if (!options[key]) setConfig(false, key);
}
}
const events = {};
function interval(period) {
const gp = moe.game();
if (!gp || gp.isPaused) return;
const opts = events[period];
if (!opts) return;
for (const option2 of opts) {
option2.script(true, { ...options }, { ...config });
}
}
function setConfig(isSet, flag2) {
if (isSet) {
config[flag2] = true;
} else {
delete config[flag2];
}
localStorage.setItem(moe.STORAGE_KEY, JSON.stringify(config));
}
async function setEvent(isSet, option2) {
try {
if (option2.period === moe.option.Period.S0立即执行) {
let game = moe.game();
if (!game) await moe.waitInit();
game = moe.game();
if (!game) {
alert(`${moe.log.PREFIX}无法完成初始化,因为游戏在10s内未加载完成。请排查网络或禁用该插件`);
return;
}
option2.script(isSet, { ...options }, { ...config });
return;
}
if (isSet) {
if (!events[option2.period]) {
events[option2.period] = [];
moe.log.console(`设置周期为${option2.period}的事件`);
setInterval(() => {
interval(option2.period);
}, option2.period);
}
events[option2.period].push(option2);
} else {
const index = events[option2.period].findIndex((o) => o === option2);
if (index >= 0) {
events[option2.period].splice(index, 1);
}
}
} finally {
setConfig(isSet, option2.flag);
}
}
function optionSelect(e) {
const target = e.currentTarget;
const flag2 = target.id.replace("moe-", "");
const option2 = options[flag2];
if (target.checked) {
setEvent(true, option2);
moe.log.game(`开启选项【${option2.name}】${option2.description.activate}`);
} else {
setEvent(false, option2);
moe.log.game(`关闭选项【${option2.name}】${option2.description.deactivate}`);
}
}
function moeHtml() {
const OPTION_STYLES = `
.moe-tabs-header {
border-bottom: 1px solid #999;
margin-bottom: 15px;
}
.moe-tab {
display: inline-block;
padding: 5px 15px;
margin-right: 5px;
text-decoration: none;
color: inherit;
}
.moe-tab.moe-active {
border: 1px solid #999;
border-bottom: none;
background: #fff;
}
`;
GM_addStyle(OPTION_STYLES);
const groupedOptions = {};
for (const key in options) {
const option2 = options[key];
if (groupedOptions[option2.panel]) {
groupedOptions[option2.panel].push(option2);
} else {
groupedOptions[option2.panel] = [option2];
}
}
const allOperators = [];
for (const panel in groupedOptions) {
allOperators.push({ panel, list: groupedOptions[panel] });
}
const bindClick = [];
const optionHtml = allOperators.map((operator) => {
operator.list.sort((a, b) => {
return (a.index || 9999) - (b.index || 9999);
});
const optionsHtml = operator.list.map((option2) => {
const id = `moe-${option2.flag}`;
bindClick.push(() => {
$(`#${id}`).on("click", optionSelect);
if (config[option2.flag]) $(`#${id}`).click();
});
return `
<span style="white-space:nowrap;">
<input class="${moe.ALL_CLASS_NAME}" id="${id}" type="checkbox" style="display:inline">
<span>${option2.name}</span>
</span>
`;
}).join("");
return `
<div>
<h4>${operator.panel}</h4>
<div style="display:flex;flex-wrap:wrap">
${optionsHtml}
</div>
</div>
`;
}).join("");
const optionsDiv = $("#optionsDiv");
if (optionsDiv.length === 0) return;
const originalContent = optionsDiv.html();
const tabsHtml = `
<a id="optionsDialogClose" href="#" class="close" onclick="gamePage.closeOptions()" style="position: absolute; top: 10px; right: 15px;">关闭</a>
<div class="moe-tabs-header" style="margin: 10px 0;">
<a href="#" class="moe-tab moe-active" data-tab="moe-game">游戏选项</a>
<a href="#" class="moe-tab" data-tab="moe-moe">MoeScript</a>
</div>
<div class="moe-tab-content" id="moe-gameTab" style="display: block;">
${originalContent}
</div>
<div class="moe-tab-content" id="moe-moeTab" style="display: none;">
<!-- 添加更多MoeScript选项 -->
${optionHtml}
</div>
`;
$("#optionsDiv").html(tabsHtml);
$(".moe-tab").on("click", function(e) {
e.preventDefault();
const targetTab = $(this).data("tab");
$(".moe-tab").removeClass("moe-active");
$(this).addClass("moe-active");
$(".moe-tab-content").hide();
$(`#${targetTab}Tab`).show();
});
for (const fn of bindClick) {
fn();
}
}
function optionPanel() {
console.log("moe: ", moe);
if (!verifyOptions()) return;
loadConfig();
moeHtml();
}
var moe;
((moe2) => {
moe2.STORAGE_KEY = "com.nuclearunicorn.kittengame.plugin.moe";
moe2.ALL_CLASS_NAME = "moe-moescript";
let init = false;
function game() {
try {
waitInit();
return gamePage;
} catch (e) {
return void 0;
}
}
moe2.game = game;
async function waitInit() {
if (init) return true;
let g = void 0;
let counter = 0;
while (!g && counter < 100) {
try {
g = gamePage;
} catch (e) {
await sleep(100);
counter++;
}
}
if (!g) return false;
if (!init) {
g.diplomacyTab.domNode.click();
await sleep(50);
g.timeTab.domNode.click();
await sleep(50);
g.bldTab.domNode.click();
init = true;
}
return true;
}
moe2.waitInit = waitInit;
((log2) => {
let timer = false;
const logs = [];
function consumer() {
const game3 = moe2.game();
if (!game3) {
setTimeout(consumer, 500);
} else {
for (const l of logs) {
game3.console.msg(l);
}
timer = false;
}
}
function plog(msg) {
logs.push(msg);
if (!timer) {
consumer();
timer = true;
}
}
function game2(msg) {
const l = `${log2.PREFIX}${msg}}`;
const g = moe2.game();
if (g) {
g.console.msg(l);
} else {
plog(l);
}
}
log2.game = game2;
log2.PREFIX = "猫国建设者挂机插件: ";
function console2(msg) {
window.console.log(`${log2.PREFIX}${msg}`);
}
log2.console = console2;
})(moe2.log || (moe2.log = {}));
moe2.operate = operate;
moe2.option = option$a;
moe2.load = optionPanel;
})(moe || (moe = {}));
const seeSky观测天空gctk = {
panel: "基本",
name: "自动观测天空",
description: {
activate: "出现天文事件时将会自动观测天空",
deactivate: "停止自动观测天空"
},
flag: "观测天空",
script: async function() {
const obsBtn = $("#observeBtn");
if (obsBtn.length === 0) return false;
moe.log.console(`检测到天空中出现一种罕见的天文现象,自动进行“观测天空”操作`);
$("#observeBtn").click();
return true;
},
/**
* 观测天空选项会持续30天(60秒)
* 但是当先前的天文事件未被观测时,新的天文事件仍有可能发生。
* 这会导致覆盖之前的事件,所以如果出现了天文事件,需要尽快处理。
*
* 时间设定为5s,会有极小概率错过天文事件(两次天文事件产生在5s内),实测错过概率< 1%
* 如果不像错过天文事件,可以将时间将时间改到3s内
*/
period: moe.option.Period.S5秒
};
seeSky观测天空gctk.script;
seeSky观测天空gctk.flag;
moe.option.regiterOption(seeSky观测天空gctk);
class GenerateByPeriod {
constructor(from2, to2, period) {
__publicField(this, "from");
__publicField(this, "to");
__publicField(this, "period");
this.from = from2;
this.to = to2;
this.period = period;
}
get panel() {
return "合成";
}
get name() {
return `${this.from}合成${this.to}`;
}
get description() {
if (this.period === moe.option.Period.S0立即执行) {
return {
activate: `立即执行合成${this.to}(激活)`,
deactivate: `立即执行合成${this.to}(关闭)`
};
}
let p;
switch (this.period) {
case moe.option.Period.S5秒:
p = "每5秒";
break;
case moe.option.Period.S15秒:
p = "每15秒";
break;
case moe.option.Period.S30秒:
p = "每30秒";
break;
case moe.option.Period.M1分钟:
p = "每分钟";
break;
case moe.option.Period.M5分钟:
p = "每5分钟";
break;
case moe.option.Period.H1小时:
p = "每小时";
break;
default:
throw new Error("未定义的时间周期");
}
return {
activate: `${p}自动将所有${this.to}合成${this.from}`,
deactivate: `停止自动合成${this.to}`
};
}
get flag() {
return `${this.from}合成${this.to}`;
}
async script() {
moe.log.console(`执行自动合成${this.to}`);
moe.operate.generateResource(this.to, GenerateType.GT_ALL);
return true;
}
}
class GenerateByRatio extends GenerateByPeriod {
constructor(from2, to2, period, ratio2) {
super(from2, to2, period);
__privateAdd(this, _ratio);
if (ratio2 <= 0 || ratio2 > 1) throw new Error("ratio must be in (0, 1]");
__privateSet(this, _ratio, ratio2);
}
get description() {
return {
activate: `将在${this.from}库存达到${__privateGet(this, _ratio) * 100}%时自动合成${this.to}`,
deactivate: `停止自动合成${this.to}`
};
}
async script() {
const rate = moe.operate.getResourceRatio(this.from);
if (rate === Infinity) {
moe.log.game(`合成${this.to}时计算异常,无法获取原料【${this.from}】仓库大小。`);
return false;
}
if (rate < __privateGet(this, _ratio)) return false;
moe.log.console(`检测到${this.from}储量达到${__privateGet(this, _ratio) * 100}%,自动合成${this.to}`);
moe.operate.generateResource(this.to, GenerateType.GT_ALL);
return true;
}
}
_ratio = new WeakMap();
class TradeByRatio extends GenerateByPeriod {
constructor(from2, to2, period, ratio2) {
super(from2, moe.operate.specialName(to2), period);
__privateAdd(this, _ratio2);
// to中存放的是该物种的中文名称
__privateAdd(this, _to);
if (ratio2 <= 0 || ratio2 > 1) throw new Error("ratio must be in (0, 1]");
__privateSet(this, _ratio2, ratio2);
__privateSet(this, _to, to2);
}
get panel() {
return "贸易";
}
get name() {
return `自动与${this.to}贸易`;
}
get flag() {
return `自动与${this.to}贸易`;
}
get description() {
return {
activate: `${this.from}达到${__privateGet(this, _ratio2) * 100}%时自动与${this.to}交易`,
deactivate: `停止自动与${this.to}贸易`
};
}
async script() {
const rate = moe.operate.getResourceRatio(this.from);
if (rate < __privateGet(this, _ratio2)) return false;
moe.log.console(`检测到${this.from}储量达到${__privateGet(this, _ratio2) * 100}%,自动与${this.to}贸易`);
moe.operate.tradeAll(__privateGet(this, _to));
return true;
}
}
_ratio2 = new WeakMap();
_to = new WeakMap();
const option$9 = moe.option;
const from$7 = "木材";
const to$7 = "木梁";
const ratio$6 = 0.95;
const generate木梁from木材 = new GenerateByRatio(from$7, to$7, option$9.Period.S30秒, ratio$6);
generate木梁from木材.oriScript = generate木梁from木材.script;
generate木梁from木材.flag;
option$9.regiterOption(generate木梁from木材);
const option$8 = moe.option;
const from$6 = "矿物";
const to$6 = "石板";
const ratio$5 = 0.95;
const generate石板from矿物 = new GenerateByRatio(from$6, to$6, option$8.Period.S30秒, ratio$5);
generate石板from矿物.oriScript = generate石板from矿物.script;
generate石板from矿物.flag;
option$8.regiterOption(generate石板from矿物);
const option$7 = moe.option;
const from$5 = "煤";
const to$5 = "钢";
const ratio$4 = 0.95;
const generate钢from煤 = new GenerateByRatio(from$5, to$5, option$7.Period.M1分钟, ratio$4);
generate钢from煤.oriScript = generate钢from煤.script;
generate钢from煤.flag;
option$7.regiterOption(generate钢from煤);
const option$6 = moe.option;
const from$4 = "铁";
const to$4 = "钢";
const ratio$3 = 0.95;
const genearte钢from铁 = new GenerateByRatio(from$4, to$4, option$6.Period.M1分钟, ratio$3);
genearte钢from铁.oriScript = genearte钢from铁.script;
genearte钢from铁.flag;
option$6.regiterOption(genearte钢from铁);
const option$5 = moe.option;
const from$3 = "铁";
const to$3 = "金属板";
const ratio$2 = 0.95;
const generate金属板from铁 = new GenerateByRatio(from$3, to$3, option$5.Period.M1分钟, ratio$2);
generate金属板from铁.oriScript = generate金属板from铁.script;
generate金属板from铁.flag;
option$5.regiterOption(generate金属板from铁);
const level$1 = 0.95;
const script$2 = async function() {
const rate = moe.operate.getResourceRatio("喵力");
if (rate < level$1) return false;
moe.log.console(`检测到喵力达到${level$1 * 100}%,自动执行打猎。`);
$("#fastHuntContainerCount").click();
return true;
};
const hunt打猎 = {
panel: "基本",
name: "自动打猎",
description: {
activate: `喵力达到${level$1 * 100}%时自动打猎`,
deactivate: "停止自动打猎"
},
flag: "打猎",
script: script$2,
/**
* 观测天空选项会持续30天(60秒)
* 但是当先前的天文事件未被观测时,新的天文事件仍有可能发生。
* 这会导致覆盖之前的事件,所以如果出现了天文事件,需要尽快处理。
*
* 时间设定为5s,会有极小概率错过天文事件(两次天文事件产生在5s内),实测错过概率< 1%
* 如果不像错过天文事件,可以将时间将时间改到3s内
*/
period: moe.option.Period.M1分钟
};
const flag = hunt打猎.flag;
moe.option.regiterOption(hunt打猎);
const level = 0.95;
const goldPromoteCat提拔小猫 = {
panel: "基本",
name: "小猫升职器",
description: {
activate: `黄金达到${level * 100}%时自动提拔小猫`,
deactivate: "停止自动提拔小猫"
},
flag: "升职器",
script: async function() {
const rate = moe.operate.getResourceRatio("黄金");
if (rate < level) return false;
moe.log.console(`检测到黄金储量达到${level * 100}%,自动提拔小猫`);
moe.operate.提拔小猫();
return true;
},
/**
* 观测天空选项会持续30天(60秒)
* 但是当先前的天文事件未被观测时,新的天文事件仍有可能发生。
* 这会导致覆盖之前的事件,所以如果出现了天文事件,需要尽快处理。
*
* 时间设定为5s,会有极小概率错过天文事件(两次天文事件产生在5s内),实测错过概率< 1%
* 如果不像错过天文事件,可以将时间将时间改到3s内
*/
period: moe.option.Period.S5秒
};
goldPromoteCat提拔小猫.script;
goldPromoteCat提拔小猫.flag;
moe.option.regiterOption(goldPromoteCat提拔小猫);
const option$4 = moe.option;
const from$2 = "毛皮";
const to$2 = "羊皮纸";
const generate羊皮纸from毛皮 = new GenerateByPeriod(from$2, to$2, option$4.Period.H1小时);
generate羊皮纸from毛皮.oriScript = generate羊皮纸from毛皮.script;
const script$1 = () => {
generate羊皮纸from毛皮.oriScript();
};
generate羊皮纸from毛皮.flag;
option$4.regiterOption(generate羊皮纸from毛皮);
const option$3 = moe.option;
const generate羊皮纸After打猎 = {
panel: "合成",
name: "自动打猎后执行合成羊皮纸",
description: {
activate: "自动打猎后将会自动合成羊皮纸,该功能需要启用【自动打猎】",
deactivate: "自动打猎后将不再自动合成羊皮纸"
},
flag: "打猎合成羊皮纸",
script: async function(activate, options2) {
const opt = options2[flag];
if (activate) {
opt.script = async function() {
const hunt = await script$2();
if (hunt) {
await sleep(1e3);
await script$1();
return true;
}
return false;
};
} else {
opt.script = script$2;
}
return true;
},
period: option$3.Period.S0立即执行
};
generate羊皮纸After打猎.script;
generate羊皮纸After打猎.flag;
option$3.regiterOption(generate羊皮纸After打猎);
const option$2 = moe.option;
const script = async function(activate) {
const game = moe.game();
if (!game) throw new Error("Game对象未加载");
if (activate) {
const timeBtn = game.timeTab.children[0].children[0].children[0];
timeBtn.toggle.linkHandler[0].click();
return true;
}
return false;
};
const 光阴似箭 = {
panel: "基本",
name: "自动开启【光阴似箭】",
description: {
activate: "在页面加载后自动开启【光阴似箭】",
deactivate: "停止自动开启【光阴似箭】"
},
flag: "光阴似箭",
script,
period: option$2.Period.S0立即执行
};
光阴似箭.flag;
option$2.regiterOption(光阴似箭);
const option$1 = moe.option;
const from$1 = "文化";
const to$1 = "手稿";
const ratio$1 = 0.95;
const generate手稿from文化 = new GenerateByRatio(from$1, to$1, option$1.Period.M10分钟, ratio$1);
generate手稿from文化.oriScript = generate手稿from文化.script;
generate手稿from文化.flag;
option$1.regiterOption(generate手稿from文化);
const option = moe.option;
const from = "喵力";
const to = moe.operate.SpecialEnum.斑马;
const ratio = 0.95;
const tradeWith斑马By喵力 = new TradeByRatio(from, to, option.Period.M10分钟, ratio);
tradeWith斑马By喵力.oriScript = tradeWith斑马By喵力.script;
tradeWith斑马By喵力.flag;
option.regiterOption(tradeWith斑马By喵力);
(function() {
moe.load();
})();