// ==UserScript== // @name Magic Way Idle // @namespace http://tampermonkey.net/ // @version 2.3.14 // @description 法师助手 // @icon https://www.milkywayidle.com/favicon.svg // @match https://www.milkywayidle.com/* // @match http://www.ratatatata.ip-ddns.com:43967/* // @run-at document-start // @grant GM_getValue // @grant GM_setValue // @grant GM_notification // @grant GM_xmlhttpRequest // @connect www.ratatatata.ip-ddns.com // @require https://cdnjs.cloudflare.com/ajax/libs/mathjs/12.4.2/math.js // @downloadURL none // ==/UserScript== (function () { // 全局URL链接配置 const global_url_config={ market:{ // 市场API本地备份 LOCAL_BACKUP : `{"time":1734029101,"market":{"Amber":{"ask":21000,"bid":20500},"Amethyst":{"ask":31000,"bid":29500},"Apple":{"ask":12,"bid":8},"Apple Gummy":{"ask":13,"bid":10},"Apple Yogurt":{"ask":350,"bid":150},"Aqua Arrow":{"ask":31000,"bid":28500},"Aqua Essence":{"ask":24,"bid":18},"Arabica Coffee Bean":{"ask":190,"bid":170},"Arcane Bow":{"ask":700000,"bid":110000},"Arcane Crossbow":{"ask":620000,"bid":480000},"Arcane Fire Staff":{"ask":480000,"bid":180000},"Arcane Log":{"ask":470,"bid":410},"Arcane Lumber":{"ask":1950,"bid":1750},"Arcane Nature Staff":{"ask":350000,"bid":170000},"Arcane Water Staff":{"ask":540000,"bid":84000},"Artisan Tea":{"ask":2425,"bid":2200},"Attack Coffee":{"ask":1500,"bid":400},"Azure Boots":{"ask":165000,"bid":8200},"Azure Brush":{"ask":36000,"bid":7000},"Azure Buckler":{"ask":37750,"bid":-1},"Azure Bulwark":{"ask":35000,"bid":-1},"Azure Cheese":{"ask":740,"bid":680},"Azure Chisel":{"ask":145000,"bid":-1},"Azure Enhancer":{"ask":62000,"bid":20000},"Azure Gauntlets":{"ask":-1,"bid":10500},"Azure Hammer":{"ask":82000,"bid":7000},"Azure Hatchet":{"ask":96000,"bid":2050},"Azure Helmet":{"ask":62000,"bid":12000},"Azure Mace":{"ask":84000,"bid":30000},"Azure Milk":{"ask":190,"bid":160},"Azure Needle":{"ask":155000,"bid":2050},"Azure Plate Body":{"ask":60000,"bid":24500},"Azure Plate Legs":{"ask":275000,"bid":2400},"Azure Pot":{"ask":140000,"bid":2100},"Azure Shears":{"ask":290000,"bid":2050},"Azure Spatula":{"ask":52000,"bid":2100},"Azure Spear":{"ask":82000,"bid":42000},"Azure Sword":{"ask":84000,"bid":3500},"Bamboo Boots":{"ask":26500,"bid":8000},"Bamboo Branch":{"ask":68,"bid":30},"Bamboo Fabric":{"ask":215,"bid":200},"Bamboo Gloves":{"ask":34000,"bid":10500},"Bamboo Hat":{"ask":42000,"bid":12000},"Bamboo Robe Bottoms":{"ask":45000,"bid":22000},"Bamboo Robe Top":{"ask":64000,"bid":5200},"Bear Essence":{"ask":115,"bid":100},"Beast Boots":{"ask":260000,"bid":8000},"Beast Bracers":{"ask":100000,"bid":10500},"Beast Chaps":{"ask":400000,"bid":15000},"Beast Hide":{"ask":24,"bid":20},"Beast Hood":{"ask":160000,"bid":12000},"Beast Leather":{"ask":620,"bid":580},"Beast Tunic":{"ask":300000,"bid":18000},"Berserk":{"ask":247500,"bid":215000},"Birch Bow":{"ask":28500,"bid":1050},"Birch Crossbow":{"ask":23500,"bid":1550},"Birch Fire Staff":{"ask":34000,"bid":800},"Birch Log":{"ask":49,"bid":38},"Birch Lumber":{"ask":560,"bid":270},"Birch Nature Staff":{"ask":34000,"bid":840},"Birch Water Staff":{"ask":34000,"bid":760},"Black Bear Fluff":{"ask":70000,"bid":56000},"Black Bear Shoes":{"ask":400000,"bid":100000},"Black Tea Leaf":{"ask":18,"bid":16},"Blackberry":{"ask":84,"bid":69},"Blackberry Cake":{"ask":520,"bid":285},"Blackberry Donut":{"ask":680,"bid":295},"Blessed Tea":{"ask":2550,"bid":1900},"Blueberry":{"ask":43,"bid":39.5},"Blueberry Cake":{"ask":680,"bid":295},"Blueberry Donut":{"ask":255,"bid":125},"Brewing Tea":{"ask":475,"bid":20},"Burble Brush":{"ask":100000,"bid":5200},"Burble Buckler":{"ask":420000,"bid":7600},"Burble Bulwark":{"ask":-1,"bid":18000},"Burble Chisel":{"ask":270000,"bid":25000},"Burble Enhancer":{"ask":450000,"bid":40000},"Burble Gauntlets":{"ask":-1,"bid":5800},"Burble Hatchet":{"ask":80000,"bid":40000},"Burble Helmet":{"ask":185000,"bid":7000},"Burble Mace":{"ask":-1,"bid":54000},"Burble Needle":{"ask":320000,"bid":26500},"Burble Plate Body":{"ask":170000,"bid":6400},"Burble Pot":{"ask":300000,"bid":27000},"Burble Shears":{"ask":-1,"bid":40000},"Burble Spatula":{"ask":115000,"bid":50000},"Burble Sword":{"ask":115000,"bid":6600},"Burble Tea Leaf":{"ask":34,"bid":25},"Cedar Bow":{"ask":-1,"bid":3500},"Cedar Fire Staff":{"ask":88000,"bid":-1},"Cedar Log":{"ask":150,"bid":122.5},"Cedar Lumber":{"ask":780,"bid":660},"Cedar Water Staff":{"ask":88000,"bid":2600},"Centaur Boots":{"ask":1000000,"bid":-1},"Centaur Hoof":{"ask":135000,"bid":125000},"Cheese Boots":{"ask":4200,"bid":120},"Cheese Brush":{"ask":4200,"bid":-1},"Cheese Buckler":{"ask":1200000,"bid":-1},"Cheese Chisel":{"ask":5600,"bid":120},"Cheese Enhancer":{"ask":5600,"bid":120},"Cheese Gauntlets":{"ask":28500,"bid":64},"Cheese Hammer":{"ask":5800,"bid":120},"Cheese Helmet":{"ask":160000,"bid":-1},"Cheese Mace":{"ask":10500,"bid":145},"Cheese Plate Body":{"ask":16500,"bid":145},"Cheese Plate Legs":{"ask":9000,"bid":115},"Cheese Pot":{"ask":6000,"bid":-1},"Cheese Spatula":{"ask":5800,"bid":120},"Cheese Spear":{"ask":15500,"bid":700},"Cheese Sword":{"ask":5000,"bid":155},"Cleave":{"ask":76000,"bid":43000},"Cocoon":{"ask":225,"bid":185},"Coin":{"ask":-1,"bid":-1},"Cotton":{"ask":81,"bid":42},"Cotton Boots":{"ask":1950,"bid":-1},"Cotton Fabric":{"ask":360,"bid":245},"Cotton Hat":{"ask":4900,"bid":-1},"Cotton Robe Bottoms":{"ask":5400,"bid":-1},"Cotton Robe Top":{"ask":-1,"bid":-1},"Crab Pincer":{"ask":8200,"bid":6800},"Crafting Tea":{"ask":1150,"bid":185},"Crimson Boots":{"ask":-1,"bid":6800},"Crimson Buckler":{"ask":-1,"bid":72000},"Crimson Bulwark":{"ask":120000,"bid":-1},"Crimson Cheese":{"ask":900,"bid":830},"Crimson Enhancer":{"ask":175000,"bid":52000},"Crimson Gauntlets":{"ask":190000,"bid":-1},"Crimson Hammer":{"ask":400000,"bid":54000},"Crimson Helmet":{"ask":150000,"bid":90000},"Crimson Mace":{"ask":160000,"bid":80000},"Crimson Milk":{"ask":290,"bid":275},"Crimson Plate Body":{"ask":250000,"bid":100000},"Crimson Plate Legs":{"ask":-1,"bid":80000},"Crimson Pot":{"ask":175000,"bid":-1},"Crimson Spatula":{"ask":140000,"bid":50000},"Crimson Spear":{"ask":-1,"bid":110000},"Crimson Sword":{"ask":680000,"bid":14000},"Crushed Amber":{"ask":1350,"bid":960},"Crushed Amethyst":{"ask":2400,"bid":1850},"Crushed Garnet":{"ask":1850,"bid":1550},"Crushed Moonstone":{"ask":3250,"bid":2650},"Crushed Pearl":{"ask":1650,"bid":760},"Cupcake":{"ask":400,"bid":225},"Donut":{"ask":470,"bid":105},"Dragon Fruit":{"ask":200,"bid":170},"Dragon Fruit Gummy":{"ask":430,"bid":360},"Earrings Of Armor":{"ask":8600000,"bid":4600000},"Earrings Of Gathering":{"ask":16000000,"bid":4600000},"Earrings Of Regeneration":{"ask":9200000,"bid":5900000},"Earrings Of Resistance":{"ask":-1,"bid":4550000},"Efficiency Tea":{"ask":1150,"bid":920},"Elemental Affinity":{"ask":185000,"bid":160000},"Emp Tea Leaf":{"ask":520,"bid":460},"Enhancing Tea":{"ask":1100,"bid":490},"Excelsa Coffee Bean":{"ask":520,"bid":475},"Eyessence":{"ask":94,"bid":82},"Fieriosa Coffee Bean":{"ask":580,"bid":480},"Fireball":{"ask":11000,"bid":10000},"Flame Arrow":{"ask":32000,"bid":25000},"Flame Blast":{"ask":90000,"bid":88000},"Flaming Cloth":{"ask":56000,"bid":42000},"Flaming Robe Top":{"ask":260000,"bid":180000},"Flax":{"ask":100,"bid":66},"Foraging Tea":{"ask":660,"bid":195},"Garnet":{"ask":30500,"bid":29500},"Gathering Tea":{"ask":700,"bid":470},"Giant Pouch":{"ask":6000000,"bid":5200000},"Ginkgo Bow":{"ask":540000,"bid":30000},"Ginkgo Crossbow":{"ask":200000,"bid":95000},"Ginkgo Log":{"ask":182.5,"bid":105},"Ginkgo Lumber":{"ask":920,"bid":760},"Ginkgo Nature Staff":{"ask":86000,"bid":15000},"Gobo Boomstick":{"ask":80000,"bid":71000},"Gobo Boots":{"ask":60000,"bid":8000},"Gobo Bracers":{"ask":86000,"bid":-1},"Gobo Essence":{"ask":98,"bid":88},"Gobo Hide":{"ask":13.5,"bid":12},"Gobo Hood":{"ask":93000,"bid":8200},"Gobo Shooter":{"ask":82000,"bid":70000},"Gobo Slasher":{"ask":84000,"bid":72000},"Gobo Smasher":{"ask":82000,"bid":72000},"Gobo Tunic":{"ask":90000,"bid":12000},"Goggles":{"ask":202500,"bid":125000},"Golem Essence":{"ask":260,"bid":240},"Granite Bludgeon":{"ask":18500000,"bid":-1},"Green Tea Leaf":{"ask":20,"bid":15},"Grizzly Bear Fluff":{"ask":68000,"bid":60000},"Gummy":{"ask":140,"bid":-1},"Heal":{"ask":76000,"bid":58000},"Holy Boots":{"ask":460000,"bid":-1},"Holy Buckler":{"ask":600000,"bid":370000},"Holy Bulwark":{"ask":680000,"bid":310000},"Holy Cheese":{"ask":1750,"bid":1650},"Holy Enhancer":{"ask":460000,"bid":-1},"Holy Gauntlets":{"ask":470000,"bid":205000},"Holy Hammer":{"ask":440000,"bid":400000},"Holy Helmet":{"ask":280000,"bid":-1},"Holy Mace":{"ask":580000,"bid":510000},"Holy Milk":{"ask":560,"bid":540},"Holy Plate Body":{"ask":1000000,"bid":310000},"Holy Plate Legs":{"ask":700000,"bid":400000},"Holy Pot":{"ask":520000,"bid":295000},"Holy Spatula":{"ask":400000,"bid":-1},"Holy Spear":{"ask":600000,"bid":400000},"Holy Sword":{"ask":460000,"bid":400000},"Icy Cloth":{"ask":52000,"bid":44000},"Icy Robe Bottoms":{"ask":200000,"bid":120000},"Icy Robe Top":{"ask":540000,"bid":185000},"Jade":{"ask":31000,"bid":29500},"Jungle Essence":{"ask":70,"bid":46},"Large Artisan's Crate":{"ask":-1,"bid":-1},"Large Pouch":{"ask":500000,"bid":360000},"Large Treasure Chest":{"ask":-1,"bid":-1},"Liberica Coffee Bean":{"ask":395,"bid":370},"Linen Boots":{"ask":33000,"bid":7000},"Linen Gloves":{"ask":36000,"bid":2800},"Linen Hat":{"ask":78000,"bid":5600},"Linen Robe Bottoms":{"ask":63000,"bid":10000},"Living Granite":{"ask":520000,"bid":480000},"Log":{"ask":72,"bid":42},"Lucky Coffee":{"ask":1750,"bid":1350},"Magic Coffee":{"ask":700,"bid":660},"Magnet":{"ask":320000,"bid":205000},"Magnifying Glass":{"ask":460000,"bid":425000},"Maim":{"ask":230000,"bid":125000},"Marsberry":{"ask":155,"bid":135},"Marsberry Donut":{"ask":790,"bid":700},"Medium Artisan's Crate":{"ask":-1,"bid":-1},"Medium Meteorite Cache":{"ask":-1,"bid":-1},"Medium Treasure Chest":{"ask":-1,"bid":-1},"Milk":{"ask":42,"bid":35},"Milking Tea":{"ask":500,"bid":205},"Minor Heal":{"ask":10500,"bid":1600},"Mooberry":{"ask":150,"bid":110},"Mooberry Cake":{"ask":930,"bid":800},"Mooberry Donut":{"ask":620,"bid":500},"Moonstone":{"ask":46000,"bid":45000},"Necklace Of Efficiency":{"ask":17000000,"bid":7800000},"Necklace Of Wisdom":{"ask":30000000,"bid":8000000},"Orange Gummy":{"ask":32,"bid":22},"Orange Yogurt":{"ask":600,"bid":300},"Panda Gloves":{"ask":430000,"bid":205000},"Peach":{"ask":62,"bid":44},"Peach Gummy":{"ask":282.5,"bid":220},"Pearl":{"ask":14000,"bid":13000},"Pierce":{"ask":-1,"bid":-1},"Pincer Gloves":{"ask":33000,"bid":13000},"Plum":{"ask":130,"bid":110},"Plum Yogurt":{"ask":720,"bid":410},"Poke":{"ask":4300,"bid":2050},"Power Coffee":{"ask":990,"bid":680},"Precision":{"ask":54000,"bid":52000},"Purpleheart Bow":{"ask":105000,"bid":31000},"Purpleheart Crossbow":{"ask":98000,"bid":45000},"Purpleheart Fire Staff":{"ask":880000,"bid":15000},"Purpleheart Lumber":{"ask":780,"bid":700},"Purpleheart Nature Staff":{"ask":100000,"bid":50000},"Purpleheart Water Staff":{"ask":-1,"bid":-1},"Quick Shot":{"ask":4100,"bid":2050},"Radiant Fabric":{"ask":2625,"bid":2475},"Radiant Fiber":{"ask":580,"bid":540},"Radiant Gloves":{"ask":185000,"bid":125000},"Radiant Robe Bottoms":{"ask":430000,"bid":360000},"Radiant Robe Top":{"ask":600000,"bid":330000},"Rain Of Arrows":{"ask":150000,"bid":145000},"Rainbow Brush":{"ask":500000,"bid":-1},"Rainbow Buckler":{"ask":-1,"bid":62000},"Rainbow Bulwark":{"ask":400000,"bid":105000},"Rainbow Chisel":{"ask":240000,"bid":60000},"Rainbow Enhancer":{"ask":222500,"bid":31000},"Rainbow Gauntlets":{"ask":370000,"bid":132500},"Rainbow Hatchet":{"ask":245000,"bid":-1},"Rainbow Helmet":{"ask":290000,"bid":78000},"Rainbow Mace":{"ask":380000,"bid":220000},"Rainbow Needle":{"ask":220000,"bid":58000},"Rainbow Plate Body":{"ask":290000,"bid":30000},"Rainbow Plate Legs":{"ask":275000,"bid":155000},"Rainbow Shears":{"ask":310000,"bid":200000},"Rainbow Spatula":{"ask":235000,"bid":86000},"Rainbow Spear":{"ask":500000,"bid":-1},"Ranged Coffee":{"ask":770,"bid":640},"Ranger Necklace":{"ask":-1,"bid":7600000},"Red Tea Leaf":{"ask":54,"bid":50},"Redwood Crossbow":{"ask":235000,"bid":120000},"Redwood Fire Staff":{"ask":200000,"bid":100000},"Redwood Log":{"ask":46,"bid":36},"Redwood Nature Staff":{"ask":300000,"bid":100000},"Redwood Water Staff":{"ask":200000,"bid":100000},"Reptile Boots":{"ask":33000,"bid":9600},"Reptile Chaps":{"ask":29000,"bid":2000},"Reptile Hide":{"ask":150,"bid":33},"Reptile Hood":{"ask":20500,"bid":760},"Reptile Tunic":{"ask":27000,"bid":1250},"Ring Of Armor":{"ask":8600000,"bid":4500000},"Ring Of Gathering":{"ask":20000000,"bid":4500000},"Ring Of Regeneration":{"ask":9600000,"bid":4500000},"Ring Of Resistance":{"ask":8400000,"bid":4500000},"Robusta Coffee Bean":{"ask":295,"bid":205},"Rough Bracers":{"ask":-1,"bid":-1},"Rough Chaps":{"ask":14500,"bid":115},"Rough Hide":{"ask":115,"bid":76},"Rough Leather":{"ask":390,"bid":370},"Rough Tunic":{"ask":10000,"bid":-1},"Scratch":{"ask":5000,"bid":2200},"Silk Boots":{"ask":80000,"bid":20000},"Silk Fabric":{"ask":1525,"bid":1300},"Silk Gloves":{"ask":90000,"bid":30000},"Silk Robe Bottoms":{"ask":260000,"bid":15000},"Silk Robe Top":{"ask":200000,"bid":18000},"Smack":{"ask":4050,"bid":2150},"Small Meteorite Cache":{"ask":-1,"bid":-1},"Small Pouch":{"ask":37500,"bid":-1},"Snail Shell":{"ask":6600,"bid":6000},"Snail Shell Helmet":{"ask":30000,"bid":13000},"Snake Fang":{"ask":3100,"bid":2150},"Sorcerer Boots":{"ask":460000,"bid":165000},"Sorcerer Essence":{"ask":122.5,"bid":110},"Sorcerer's Sole":{"ask":75000,"bid":72000},"Spaceberry Cake":{"ask":1650,"bid":1350},"Spaceberry Donut":{"ask":980,"bid":880},"Spacia Coffee Bean":{"ask":860,"bid":800},"Stalactite Shard":{"ask":495000,"bid":470000},"Stalactite Spear":{"ask":-1,"bid":8000000},"Stamina Coffee":{"ask":540,"bid":250},"Star Fruit":{"ask":410,"bid":380},"Star Fruit Gummy":{"ask":880,"bid":860},"Star Fruit Yogurt":{"ask":1400,"bid":1350},"Strawberry Cake":{"ask":740,"bid":46},"Strawberry Donut":{"ask":285,"bid":40},"Stunning Blow":{"ask":267500,"bid":185000},"Super Attack Coffee":{"ask":3700,"bid":2100},"Super Brewing Tea":{"ask":3400,"bid":-1},"Super Cheesesmithing Tea":{"ask":4350,"bid":2000},"Super Crafting Tea":{"ask":5000,"bid":3800},"Super Defense Coffee":{"ask":3800,"bid":2400},"Super Enhancing Tea":{"ask":4100,"bid":3400},"Super Foraging Tea":{"ask":3900,"bid":1450},"Super Magic Coffee":{"ask":4200,"bid":4100},"Super Milking Tea":{"ask":6400,"bid":-1},"Super Power Coffee":{"ask":4600,"bid":4200},"Super Stamina Coffee":{"ask":2800,"bid":2400},"Super Tailoring Tea":{"ask":7200,"bid":-1},"Super Woodcutting Tea":{"ask":3900,"bid":2250},"Sweep":{"ask":98000,"bid":78000},"Swiftness Coffee":{"ask":2400,"bid":1700},"Tailoring Tea":{"ask":640,"bid":400},"Tome Of The Elements":{"ask":1000000,"bid":760000},"Toughness":{"ask":56000,"bid":52000},"Toxic Pollen":{"ask":105000,"bid":80000},"Turtle Shell Body":{"ask":44000,"bid":-1},"Turtle Shell Legs":{"ask":170000,"bid":-1},"Twilight Essence":{"ask":275,"bid":240},"Umbral Bracers":{"ask":165000,"bid":54000},"Umbral Chaps":{"ask":350000,"bid":39000},"Umbral Hide":{"ask":260,"bid":210},"Umbral Leather":{"ask":2075,"bid":1900},"Umbral Tunic":{"ask":350000,"bid":45000},"Vampire Fang":{"ask":500000,"bid":470000},"Vampirism":{"ask":48000,"bid":22500},"Verdant Boots":{"ask":24500,"bid":-1},"Verdant Brush":{"ask":-1,"bid":1150},"Verdant Bulwark":{"ask":28750,"bid":-1},"Verdant Cheese":{"ask":520,"bid":440},"Verdant Chisel":{"ask":560000,"bid":12000},"Verdant Gauntlets":{"ask":98000,"bid":1600},"Verdant Hammer":{"ask":33000,"bid":-1},"Verdant Hatchet":{"ask":140000,"bid":600},"Verdant Mace":{"ask":38000,"bid":11500},"Verdant Milk":{"ask":120,"bid":98},"Verdant Needle":{"ask":47000,"bid":12000},"Verdant Plate Legs":{"ask":98000,"bid":2600},"Verdant Pot":{"ask":90000,"bid":600},"Verdant Shears":{"ask":-1,"bid":-1},"Verdant Spear":{"ask":38000,"bid":-1},"Verdant Sword":{"ask":38000,"bid":-1},"Vision Helmet":{"ask":182500,"bid":56000},"Water Strike":{"ask":8700,"bid":8200},"Werewolf Claw":{"ask":580000,"bid":470000},"Werewolf Slasher":{"ask":12000000,"bid":6600000},"Wisdom Coffee":{"ask":1350,"bid":1250},"Wisdom Tea":{"ask":890,"bid":820},"Wizard Necklace":{"ask":15500000,"bid":7600000},"Wooden Bow":{"ask":19500,"bid":195},"Wooden Crossbow":{"ask":9100,"bid":145},"Wooden Fire Staff":{"ask":11500,"bid":145},"Wooden Water Staff":{"ask":2450,"bid":155},"Yogurt":{"ask":1550,"bid":200},"Burble Boots":{"ask":96000,"bid":35000},"Burble Cheese":{"ask":1200,"bid":900},"Burble Hammer":{"ask":350000,"bid":-1},"Burble Milk":{"ask":270,"bid":207.5},"Cedar Nature Staff":{"ask":88000,"bid":-1},"Cheese":{"ask":240,"bid":195},"Cheese Bulwark":{"ask":-1,"bid":-1},"Cheese Hatchet":{"ask":5800,"bid":120},"Cheese Needle":{"ask":6000,"bid":2950},"Cheese Shears":{"ask":3600,"bid":-1},"Cheesesmithing Tea":{"ask":840,"bid":400},"Cooking Tea":{"ask":430,"bid":26},"Cotton Gloves":{"ask":2650,"bid":370},"Cowbell":{"ask":-1,"bid":-1},"Crimson Brush":{"ask":109999.5,"bid":15500},"Crimson Chisel":{"ask":440000,"bid":30000},"Crimson Hatchet":{"ask":190000,"bid":45000},"Crimson Shears":{"ask":165000,"bid":-1},"Critical Coffee":{"ask":3100,"bid":2350},"Crushed Jade":{"ask":2250,"bid":1750},"Defense Coffee":{"ask":680,"bid":370},"Dragon Fruit Yogurt":{"ask":980,"bid":920},"Flaming Robe Bottoms":{"ask":280000,"bid":120000},"Frenzy":{"ask":175000,"bid":170000},"Gobo Leather":{"ask":540,"bid":370},"Holy Chisel":{"ask":460000,"bid":400000},"Holy Hatchet":{"ask":480000,"bid":410000},"Holy Needle":{"ask":590000,"bid":400000},"Holy Shears":{"ask":560000,"bid":410000},"Ice Spear":{"ask":29500,"bid":27250},"Intelligence Coffee":{"ask":580,"bid":410},"Linen Fabric":{"ask":340,"bid":285},"Linen Robe Top":{"ask":72000,"bid":10000},"Lumber":{"ask":370,"bid":105},"Mirror Of Protection":{"ask":9200000,"bid":8500000},"Moolong Tea Leaf":{"ask":33,"bid":32},"Orange":{"ask":13,"bid":7},"Panda Fluff":{"ask":74000,"bid":54000},"Peach Yogurt":{"ask":720,"bid":680},"Plum Gummy":{"ask":105,"bid":70},"Processing Tea":{"ask":2150,"bid":1850},"Purpleheart Log":{"ask":160,"bid":120},"Radiant Boots":{"ask":220000,"bid":125000},"Radiant Hat":{"ask":380000,"bid":295000},"Rainbow Boots":{"ask":207500,"bid":14500},"Rainbow Cheese":{"ask":1250,"bid":1125},"Rainbow Hammer":{"ask":200000,"bid":50000},"Rainbow Milk":{"ask":310,"bid":290},"Rainbow Pot":{"ask":250000,"bid":70000},"Rainbow Sword":{"ask":430000,"bid":230000},"Redwood Bow":{"ask":-1,"bid":120000},"Redwood Lumber":{"ask":560,"bid":480},"Reptile Bracers":{"ask":42000,"bid":-1},"Reptile Leather":{"ask":480,"bid":370},"Ring Of Rare Find":{"ask":-1,"bid":4500000},"Rough Boots":{"ask":1500,"bid":-1},"Rough Hood":{"ask":10000,"bid":-1},"Shard Of Protection":{"ask":50000,"bid":49000},"Silk Hat":{"ask":130000,"bid":11000},"Small Artisan's Crate":{"ask":-1,"bid":-1},"Small Treasure Chest":{"ask":-1,"bid":-1},"Snake Fang Dirk":{"ask":13000,"bid":5200},"Spaceberry":{"ask":185,"bid":170},"Spike Shell":{"ask":68000,"bid":25000},"Star Fragment":{"ask":14000,"bid":13000},"Strawberry":{"ask":100,"bid":82},"Super Cooking Tea":{"ask":7400,"bid":1650},"Super Intelligence Coffee":{"ask":2850,"bid":2000},"Super Ranged Coffee":{"ask":4200,"bid":4100},"Swamp Essence":{"ask":42,"bid":36},"Tome Of Healing":{"ask":105000,"bid":86000},"Turtle Shell":{"ask":10000,"bid":8200},"Umbral Boots":{"ask":165000,"bid":54000},"Umbral Hood":{"ask":295000,"bid":220000},"Vampire Fang Dirk":{"ask":10000000,"bid":5600000},"Verdant Buckler":{"ask":-1,"bid":-1},"Verdant Enhancer":{"ask":88000,"bid":15000},"Verdant Helmet":{"ask":98000,"bid":1600},"Verdant Spatula":{"ask":145000,"bid":-1},"Vision Shield":{"ask":600000,"bid":150000},"Wheat":{"ask":33.5,"bid":30.5},"Woodcutting Tea":{"ask":780,"bid":360},"Wooden Nature Staff":{"ask":170000,"bid":180},"Cedar Crossbow":{"ask":48500,"bid":25500},"Earrings Of Rare Find":{"ask":-1,"bid":4600000},"Egg":{"ask":38,"bid":31.5},"Entangle":{"ask":12000,"bid":11500},"Fighter Necklace":{"ask":16000000,"bid":7600000},"Gator Vest":{"ask":28500,"bid":16000},"Ginkgo Fire Staff":{"ask":200000,"bid":20000},"Gobo Chaps":{"ask":78000,"bid":31000},"Gobo Stabber":{"ask":89000,"bid":72000},"Gourmet Tea":{"ask":620,"bid":520},"Grizzly Bear Shoes":{"ask":460000,"bid":280000},"Holy Brush":{"ask":520000,"bid":400000},"Large Meteorite Cache":{"ask":-1,"bid":-1},"Magnetic Gloves":{"ask":4000000,"bid":1000000},"Marsberry Cake":{"ask":1150,"bid":980},"Medium Pouch":{"ask":100000,"bid":-1},"Polar Bear Fluff":{"ask":98000,"bid":74000},"Verdant Plate Body":{"ask":58000,"bid":660},"Ginkgo Water Staff":{"ask":190000,"bid":15000},"Polar Bear Shoes":{"ask":760000,"bid":450000},"Sugar":{"ask":9,"bid":8},"Crimson Needle":{"ask":430000,"bid":37000},"Burble Plate Legs":{"ask":92000,"bid":6400},"Burble Spear":{"ask":190000,"bid":52000},"Arcane Shield":{"ask":217500,"bid":120000},"Birch Shield":{"ask":62000,"bid":500},"Cedar Shield":{"ask":100000,"bid":4000},"Ginkgo Shield":{"ask":580000,"bid":-1},"Purpleheart Shield":{"ask":200000,"bid":30000},"Redwood Shield":{"ask":200000,"bid":52000},"Sighted Bracers":{"ask":700000,"bid":-1},"Spiked Bulwark":{"ask":8600000,"bid":-1},"Wooden Shield":{"ask":2450,"bid":-1},"Advanced Task Ring":{"ask":-1,"bid":-1},"Basic Task Ring":{"ask":-1,"bid":-1},"Expert Task Ring":{"ask":-1,"bid":-1},"Purple's Gift":{"ask":-1,"bid":-1},"Task Crystal":{"ask":-1,"bid":-1},"Task Token":{"ask":-1,"bid":-1},"Abyssal Essence":{"ask":252.5,"bid":240},"Channeling Coffee":{"ask":2575,"bid":2200},"Chrono Gloves":{"ask":7200000,"bid":-1},"Chrono Sphere":{"ask":600000,"bid":520000},"Collector's Boots":{"ask":3200000,"bid":2450000},"Colossus Core":{"ask":890000,"bid":820000},"Colossus Plate Body":{"ask":8400000,"bid":1500000},"Colossus Plate Legs":{"ask":-1,"bid":1200000},"Demonic Core":{"ask":880000,"bid":860000},"Demonic Plate Body":{"ask":10000000,"bid":5200000},"Demonic Plate Legs":{"ask":12000000,"bid":3000000},"Elusiveness":{"ask":32000,"bid":23500},"Enchanted Gloves":{"ask":6600000,"bid":5000000},"Eye Of The Watcher":{"ask":560000,"bid":500000},"Eye Watch":{"ask":5800000,"bid":4900000},"Firestorm":{"ask":360000,"bid":350000},"Fluffy Red Hat":{"ask":6800000,"bid":4500000},"Frost Sphere":{"ask":480000,"bid":430000},"Frost Staff":{"ask":9800000,"bid":6000000},"Frost Surge":{"ask":320000,"bid":300000},"Gobo Defender":{"ask":560000,"bid":400000},"Gobo Rag":{"ask":340000,"bid":265000},"Infernal Battlestaff":{"ask":13000000,"bid":-1},"Infernal Ember":{"ask":580000,"bid":490000},"Luna Robe Bottoms":{"ask":1950000,"bid":96000},"Luna Robe Top":{"ask":2350000,"bid":-1},"Luna Wing":{"ask":200000,"bid":140000},"Marine Chaps":{"ask":370000,"bid":150000},"Marine Scale":{"ask":50000,"bid":26000},"Marine Tunic":{"ask":560000,"bid":175000},"Nature's Veil":{"ask":690000,"bid":500000},"Puncture":{"ask":130000,"bid":115000},"Red Chef's Hat":{"ask":4800000,"bid":4000000},"Red Panda Fluff":{"ask":470000,"bid":440000},"Revenant Anima":{"ask":880000,"bid":860000},"Revenant Chaps":{"ask":7600000,"bid":4300000},"Revenant Tunic":{"ask":9400000,"bid":6400000},"Shoebill Feather":{"ask":76000,"bid":41000},"Shoebill Shoes":{"ask":-1,"bid":350000},"Silencing Shot":{"ask":130000,"bid":125000},"Soul Fragment":{"ask":500000,"bid":480000},"Soul Hunter Crossbow":{"ask":4999999.5,"bid":2700000},"Steady Shot":{"ask":150000,"bid":145000},"Treant Bark":{"ask":48000,"bid":31000},"Treant Shield":{"ask":210000,"bid":105000},"Vampiric Bow":{"ask":-1,"bid":3600000},"Watchful Relic":{"ask":9800000,"bid":4500000},"Bag Of 10 Cowbells":{"ask":500000,"bid":460000},"Aqua Aura":{"ask":1300000,"bid":1225000},"Critical Aura":{"ask":6000000,"bid":2850000},"Fierce Aura":{"ask":6400000,"bid":3700000},"Flame Aura":{"ask":1650000,"bid":1450000},"Insanity":{"ask":3400000,"bid":2700000},"Invincible":{"ask":1600000,"bid":1250000},"Provoke":{"ask":76000,"bid":23500},"Quick Aid":{"ask":200000,"bid":190000},"Rejuvenate":{"ask":320000,"bid":270000},"Revive":{"ask":1350000,"bid":1175000},"Speed Aura":{"ask":2950000,"bid":2075000},"Sylvan Aura":{"ask":3100000,"bid":1600000},"Taunt":{"ask":64000,"bid":54000},"Acrobatic Hood":{"ask":50000000,"bid":40000000},"Acrobat's Ribbon":{"ask":3400000,"bid":3300000},"Bishop's Codex":{"ask":81000000,"bid":50000000},"Bishop's Scroll":{"ask":5800000,"bid":5200000},"Blue Key Fragment":{"ask":360000,"bid":330000},"Brown Key Fragment":{"ask":425000,"bid":410000},"Burning Key Fragment":{"ask":1350000,"bid":1300000},"Chaotic Chain":{"ask":5200000,"bid":4900000},"Chaotic Flail":{"ask":-1,"bid":100000000},"Chimerical Chest":{"ask":-1,"bid":-1},"Chimerical Essence":{"ask":400,"bid":380},"Chimerical Key":{"ask":-1,"bid":-1},"Chimerical Quiver":{"ask":-1,"bid":-1},"Crippling Slash":{"ask":54000,"bid":26000},"Cursed Ball":{"ask":3500000,"bid":3000000},"Cursed Bow":{"ask":-1,"bid":-1},"Dark Key Fragment":{"ask":920000,"bid":800000},"Dodocamel Gauntlets":{"ask":-1,"bid":16500000},"Dodocamel Plume":{"ask":3300000,"bid":3100000},"Earrings Of Threat":{"ask":-1,"bid":-1},"Enchanted Chest":{"ask":-1,"bid":-1},"Enchanted Cloak":{"ask":-1,"bid":-1},"Enchanted Essence":{"ask":1600,"bid":1500},"Enchanted Key":{"ask":-1,"bid":-1},"Green Key Fragment":{"ask":285000,"bid":255000},"Griffin Chaps":{"ask":-1,"bid":-1},"Griffin Leather":{"ask":940000,"bid":560000},"Griffin Tunic":{"ask":-1,"bid":-1},"Impale":{"ask":31000,"bid":26750},"Jackalope Antler":{"ask":1850000,"bid":1650000},"Jackalope Staff":{"ask":35000000,"bid":-1},"Knight's Aegis":{"ask":90000000,"bid":-1},"Knight's Ingot":{"ask":5400000,"bid":5100000},"Magician's Cloth":{"ask":3700000,"bid":3300000},"Magician's Hat":{"ask":-1,"bid":45000000},"Mana Spring":{"ask":205000,"bid":160000},"Manticore Shield":{"ask":-1,"bid":12750000},"Manticore Sting":{"ask":1850000,"bid":1700000},"Orange Key Fragment":{"ask":290000,"bid":280000},"Penetrating Shot":{"ask":210000,"bid":200000},"Penetrating Strike":{"ask":42000,"bid":36000},"Pestilent Shot":{"ask":31000,"bid":27000},"Purple Key Fragment":{"ask":285000,"bid":265000},"Regal Jewel":{"ask":5800000,"bid":5400000},"Regal Sword":{"ask":280000000,"bid":145000000},"Ring Of Threat":{"ask":-1,"bid":-1},"Royal Cloth":{"ask":5800000,"bid":5400000},"Royal Fire Robe Bottoms":{"ask":66000000,"bid":46000000},"Royal Fire Robe Top":{"ask":-1,"bid":60000000},"Royal Nature Robe Bottoms":{"ask":-1,"bid":47000000},"Royal Nature Robe Top":{"ask":-1,"bid":50000000},"Royal Water Robe Bottoms":{"ask":72000000,"bid":38000000},"Royal Water Robe Top":{"ask":-1,"bid":58000000},"Sinister Cape":{"ask":-1,"bid":-1},"Sinister Chest":{"ask":-1,"bid":-1},"Sinister Essence":{"ask":750,"bid":720},"Sinister Key":{"ask":-1,"bid":-1},"Smoke Burst":{"ask":52000,"bid":20500},"Stone Key Fragment":{"ask":1550000,"bid":1500000},"Sundering Crossbow":{"ask":-1,"bid":220000000},"Sundering Jewel":{"ask":8800000,"bid":7800000},"White Key Fragment":{"ask":800000,"bid":740000},"Arcane Reflection":{"ask":56000,"bid":53000},"Chimerical Chest Key":{"ask":1350000,"bid":1250000},"Chimerical Entry Key":{"ask":350000,"bid":260000},"Enchanted Chest Key":{"ask":3800000,"bid":3700000},"Enchanted Entry Key":{"ask":620000,"bid":600000},"Griffin Bulwark":{"ask":-1,"bid":94000000},"Griffin Talon":{"ask":3400000,"bid":3100000},"Sinister Chest Key":{"ask":2050000,"bid":1500000},"Sinister Entry Key":{"ask":410000,"bid":390000},"Advanced Task Badge":{"ask":-1,"bid":-1},"Alchemy Essence":{"ask":310,"bid":237.5},"Alchemy Tea":{"ask":1000,"bid":760},"Azure Alembic":{"ask":68000,"bid":15000},"Basic Task Badge":{"ask":-1,"bid":-1},"Brewing Essence":{"ask":280,"bid":220},"Burble Alembic":{"ask":860000,"bid":35999.5},"Catalyst Of Coinification":{"ask":4900,"bid":4100},"Catalyst Of Decomposition":{"ask":6900,"bid":4500},"Catalyst Of Transmutation":{"ask":8700,"bid":7000},"Catalytic Tea":{"ask":2300,"bid":2150},"Cheese Alembic":{"ask":5400,"bid":120},"Cheesesmithing Essence":{"ask":390,"bid":310},"Chimerical Token":{"ask":-1,"bid":-1},"Cooking Essence":{"ask":270,"bid":250},"Crafting Essence":{"ask":370,"bid":310},"Crimson Alembic":{"ask":460000,"bid":54000},"Crushed Philosopher's Stone":{"ask":2100000,"bid":1750000},"Crushed Sunstone":{"ask":7000,"bid":6600},"Earrings Of Critical Strike":{"ask":11000000,"bid":5800000},"Earrings Of Essence Find":{"ask":7800000,"bid":4500000},"Enchanted Token":{"ask":-1,"bid":-1},"Enhancing Essence":{"ask":820,"bid":740},"Expert Task Badge":{"ask":-1,"bid":-1},"Foraging Essence":{"ask":270,"bid":227.5},"Gluttonous Energy":{"ask":15500000,"bid":12500000},"Gluttonous Pouch":{"ask":-1,"bid":23500000},"Guzzling Energy":{"ask":35000000,"bid":33000000},"Guzzling Pouch":{"ask":-1,"bid":370000000},"Holy Alembic":{"ask":500000,"bid":440000},"Milking Essence":{"ask":285,"bid":250},"Necklace Of Speed":{"ask":25000000,"bid":9600000},"Philosopher's Earrings":{"ask":-1,"bid":250000000},"Philosopher's Necklace":{"ask":600000000,"bid":300000000},"Philosopher's Ring":{"ask":-1,"bid":-1},"Philosopher's Stone":{"ask":500000000,"bid":470000000},"Prime Catalyst":{"ask":350000,"bid":220000},"Rainbow Alembic":{"ask":330000,"bid":-1},"Ring Of Critical Strike":{"ask":9400000,"bid":5600000},"Ring Of Essence Find":{"ask":9800000,"bid":4500000},"Sinister Token":{"ask":-1,"bid":-1},"Sunstone":{"ask":460000,"bid":440000},"Super Alchemy Tea":{"ask":4500,"bid":-1},"Tailoring Essence":{"ask":300,"bid":240},"Ultra Alchemy Tea":{"ask":9200,"bid":8400},"Ultra Attack Coffee":{"ask":12500,"bid":5800},"Ultra Brewing Tea":{"ask":56000,"bid":-1},"Ultra Cheesesmithing Tea":{"ask":12250,"bid":-1},"Ultra Cooking Tea":{"ask":17000,"bid":-1},"Ultra Crafting Tea":{"ask":19000,"bid":-1},"Ultra Defense Coffee":{"ask":13500,"bid":8800},"Ultra Enhancing Tea":{"ask":10500,"bid":8600},"Ultra Foraging Tea":{"ask":7800,"bid":5600},"Ultra Intelligence Coffee":{"ask":14000,"bid":-1},"Ultra Magic Coffee":{"ask":11500,"bid":11000},"Ultra Milking Tea":{"ask":22750,"bid":1000},"Ultra Power Coffee":{"ask":11500,"bid":10750},"Ultra Ranged Coffee":{"ask":11500,"bid":10000},"Ultra Stamina Coffee":{"ask":13000,"bid":6000},"Ultra Tailoring Tea":{"ask":17000,"bid":-1},"Ultra Woodcutting Tea":{"ask":14500,"bid":-1},"Verdant Alembic":{"ask":34000,"bid":-1},"Woodcutting Essence":{"ask":330,"bid":255}}}`, // 市场API median算法 API_URL : "https://raw.githubusercontent.com/holychikenz/MWIApi/main/medianmarket.json", // 市场API 香港服务器备份 API_URL_BACKUP:"http://43.129.194.214:5500/apijson" }, recource:{ // 2024.12.21 SVG图标备份 用于保存原始圣系列装备图标 OLD_SVG_URL : "https://raw.githubusercontent.com/kobayashi7777/milky-way-idel-resource/main/items_sprite.3999af53.svg", HOLY_ITEM_BACKUP : ``, // Magic Way Idle Logo 右侧文字 MAGIC_WAY_IDLE_TITLE : 'https://tupian.li/images/2024/10/03/66fd73f009f84.png' }, magic_api:{ // 服务器存活状态,万一哪天服务器挂了所有依赖数据库的服务将都不可用 SERVER_ALIVE:true, // 服务器域名 SERVER_DOMAIN:"ratatatata.ip-ddns.com", // QQ秀上传接口 QQ_SHOW:"http://www.ratatatata.ip-ddns.com:43967/api/qqshow.php", // 个人信息上传接口 PROFILE_SHARED_UPLOAD:"http://www.ratatatata.ip-ddns.com:43967/api/uploadProfileShared.php", // 组队信息上传接口 PARTY_INFO:"http://www.ratatatata.ip-ddns.com:43967/api/partyInfo.php", // 注册使用角色 REGISTERCHARACTER : "http://www.ratatatata.ip-ddns.com:43967/api/registerCharacter.php" } }; // 功能开启设置 let settingsMap = { replaceMagicWayIdleLogo: { id: "replaceMagicWayIdleLogo", desc:"LOGO替换:左上角LOGO替换为Maigc May Idle", isTrue: true, }, deathNotify: { id: "deathNotify", desc:"死亡报警:队伍中有角色死亡时立即弹窗报警", isTrue: true, }, marketPriceUpdate: { id: "marketPriceUpdate", desc:"价格更新:通过手动查看市场中物品价格,强制更新marketAPI缓存", isTrue: true, }, qqShow: { id: "qqShow", desc:"启用QQ秀:原MWI玩家图标替换功能,现支持即时更换头像", isTrue: true, }, taskSorting: { id: "taskSorting", desc:"任务排序:将任务按照战斗地图顺序自动排列。本功能依赖MWItool,没装的也是神人了", isTrue: true, }, taskValue: { id: "taskValue", desc:"任务价值:显示每个任务的期望收益。本功能依赖食用工具,下载链接附后", isTrue: true, }, MWIToolsUIStyle: { id: "MWIToolsUIStyle", desc:"UI风格:修改MWItool的UI风格与系统UI风格一致", isTrue: true, }, marketFreezeFunds: { id: "marketFreezeFunds", desc:"冻结资金:显示撤单后可获取金币", isTrue: true, }, oldHolyItem: { id: "oldHolyItem", desc:"圣物品图标:显示原版圣系列物品图标", isTrue: false, } } // 全局变量 let globalVariable={ gameRawData:{ // 游戏基础数据 initClientData : null, // 老SVG图标DOM oldHolySvgDOM : null }, dependency:{ // 玩家是否安装插件"[银河奶牛]食用工具" isInstallEdibleTools : false, // 玩家是否安装插件"MWITools" isInstallMWITools : false }, replaceMagicWayIdleLogo:{ isReplaceable : false }, deathNotify : { // 队伍中玩家信息 battleMembers : {}, // 是否刚进入游戏,继续上次战斗 isBattleBegin : false }, qqShow:{ // 保存玩家QQ秀链接 replacementTargets : {}, // 图标替换观察者 observer : null, characterName : null }, market:{ // 是否启用市场API本地备份 isUsingLocalMarketBackup : false, // 当前冻结资金金额 freezeFundsValue : null, // 冻结资金更新标记 freezeFundsUpdateFlag : false }, task : { // 是否处于任务界面 isTaskSortable : false, // 战斗任务索引,使战斗任务始终处于其他任务后面 taskBattleIndex: 99, // 任务类型排序规则 taskOrderIndex : { Milking: 1, Foraging: 2, Woodcutting: 3, Cheesesmithing: 4, Crafting: 5, Tailoring: 6, Cooking: 7, Brewing: 8, Enhancing: 9, Defeat: 99, //战斗处于其他任务后面 } } }; // 主函数 scriptMain(); function scriptMain(){ if (document.URL.includes("milkywayidle.com")) { gameMain(); }else if(document.URL.includes(global_url_config.magic_api.SERVER_DOMAIN)){ magicMain(); } } // 游戏主函数 function gameMain(){ // IOS必定报错,不可与业务逻辑合并。移动设备无弹窗无需修复 try{ // 获取通知权限 Notification.requestPermission().then(function(result) { if (result === 'denied') { console.info('无法获取通知权限,强制关闭死亡报警'); return; } if (result === 'default') { return; } }); }catch(error){ console.error(error); } try{ // 加载功能设置 readSettings(); // 加载游戏基础数据 globalVariable.gameRawData.initClientData = JSON.parse(localStorage.getItem("initClientData")); // 判断依赖:食用工具是否安装 if('Edible_Tools' in localStorage)globalVariable.dependency.isInstallEdibleTools=true; // 判断依赖:MWITools是否安装 if('script_settingsMap' in localStorage)globalVariable.dependency.isInstallMWITools=true; // 加载老图标资源 loadOldHolySvg(); // 拦截WebSocket hookWebSocket(); // 若功能设置开启,且服务器存活 => 开启QQ秀功能 if(settingsMap.qqShow.isTrue && global_url_config.magic_api.SERVER_ALIVE){ // 优先从缓存加载QQ秀 if('magic_qqshow_cache' in localStorage){ globalVariable.qqShow.replacementTargets=JSON.parse(localStorage.getItem("magic_qqshow_cache")); } if('magic_qqshow_cache_timestamp' in localStorage){ // 若缓存过期(有效期 1 天) => 立即更新缓存 if(Math.abs(Date.now()- localStorage.getItem("magic_qqshow_cache_timestamp"))>86400000)getQQShowData(); }else{ // 未找到缓存 => 立即更新缓存 getQQShowData(); } // 初始化观察者,分配替换目标 initQQShowObserver(); // 启动观察者,替换QQ秀 globalVariable.qqShow.observer.observe(document, { attributes: false, childList: true, subtree: true }); } // 统一观察者 let globalObserver=new MutationObserver(function (mutationsList, observer) { if(settingsMap.replaceMagicWayIdleLogo.isTrue)replaceMagicWayIdleLogo(); // 任务排序 & 显示任务价值,依赖MWItool if(globalVariable.dependency.isInstallMWITools)autoClickTaskManager(); // 显示QQ秀提交UI if(settingsMap.qqShow.isTrue && global_url_config.magic_api.SERVER_ALIVE)addQQshowButton(); // 显示冻结资金 if(settingsMap.marketFreezeFunds.isTrue)showMarketFreezeFunds(); // 修改MWIToolsUI风格 if(settingsMap.MWIToolsUIStyle.isTrue)fixMWIToolsUIStyle(); // 修改神圣奶酪系列道具图标 if(settingsMap.oldHolyItem.isTrue)replaceHolyItemIcon(); // 显示功能设置面板 addSettingMenu(); }); globalObserver.observe(document,{ childList: true, subtree: true }); globalVariable.deathNotify.isBattleBegin=true; }catch(error){ console.error(error); } } // 拦截WS function hookWebSocket() { const dataProperty = Object.getOwnPropertyDescriptor(MessageEvent.prototype, "data"); const oriGet = dataProperty.get; dataProperty.get = hookedGet; Object.defineProperty(MessageEvent.prototype, "data", dataProperty); function hookedGet() { const socket = this.currentTarget; if (!(socket instanceof WebSocket)) { return oriGet.call(this); } if (socket.url.indexOf("api.milkywayidle.com/ws") <= -1 && socket.url.indexOf("api-test.milkywayidle.com/ws") <= -1) { return oriGet.call(this); } const message = oriGet.call(this); Object.defineProperty(this, "data", { value: message }); return handleMessage(message); } } // WS拦截后处理,主进程 function handleMessage(message,debug=false) { let obj = JSON.parse(message); if (obj && obj.type === "init_character_data") { // 切角色,再次刷新左上角LOGO globalVariable.replaceMagicWayIdleLogo.isReplaceable = true; // 读取角色名称用于上传QQ秀 globalVariable.qqShow.characterName=obj.character.name; // 刚进入游戏,可能继续上次战斗 => 标记为刚进入战斗 globalVariable.deathNotify.isBattleBegin=true; // 战斗排行 addRankButton(); // 组队情况 addPartyButton(); // 读取背包 uploadInitCharacterData(obj); globalVariable.market.freezeFundsValue=calculateMarketFreezeFunds(obj.myMarketListings); }else if (obj && obj.type === "new_battle") { // 死亡报警 if(settingsMap.deathNotify.isTrue)notifyDeath(obj); } else if (obj && obj.type === "battle_updated") { // 死亡报警 if(settingsMap.deathNotify.isTrue)notifyDeath(obj); }else if (obj && obj.type === "profile_shared"){ // 上传个人资料 uploadProfileShared(obj); }else if (obj && obj.type === "market_item_order_books_updated") { // 强制刷新市场价格 if(settingsMap.marketPriceUpdate.isTrue)marketPriceUpdate(obj); }else if (obj && obj.type === "actions_updated") { // 切换行动,可能开始战斗 => 标记为刚进入战斗 globalVariable.deathNotify.isBattleBegin=true; }else if(obj && obj.type ==="market_listings_updated"){ // 维护冻结资金挂单、撤单 updateMarketFreezeFunds(obj); } //other return message; } // 数据页主函数 function magicMain(){ let characterName=GM_getValue("magic_register_character"); if(!characterName)return; // 组队数据需要有人来上传,人人白嫖,脚本就没法获取真实数据 if(!checkCookieExists("character_cookie")){ document.cookie = `character_cookie=${characterName}; `; location.reload(); } } // 加载功能设置面板 function addSettingMenu(){ const targetNode = document.querySelector("div.SettingsPanel_profileTab__214Bj"); if (targetNode) { if (!targetNode.querySelector("#script_settings_magic_way_idle")) { targetNode.insertAdjacentHTML("beforeend", `
`); const insertElem = targetNode.querySelector("div#script_settings_magic_way_idle"); insertElem.insertAdjacentHTML( "beforeend", `
${ "MagicWayIdle 设置 (刷新生效):" }

` ); for (const setting of Object.values(settingsMap)) { insertElem.insertAdjacentHTML( "beforeend", `
${ setting.desc }

` ); } insertElem.insertAdjacentHTML( "beforeend", `
${ "食用工具下载: https://greasyfork.org/zh-CN 搜索 [银河奶牛]食用工具" }

` ); insertElem.addEventListener("change", saveSettings); } } } // 保存功能设置 function saveSettings() { for (const checkbox of document.querySelectorAll("div#script_settings_magic_way_idle input")) { settingsMap[checkbox.id].isTrue = checkbox.checked; localStorage.setItem("magic_script_settings", JSON.stringify(settingsMap)); } } // 加载功能设置 function readSettings() { const local_storage = localStorage.getItem("magic_script_settings"); if (local_storage) { const obj = JSON.parse(local_storage); for (const option of Object.values(obj)) { if (settingsMap.hasOwnProperty(option.id)) { settingsMap[option.id].isTrue = option.isTrue; } } } } // LOGO替换 function replaceMagicWayIdleLogo() { //本次登录已替换过Logo if(!globalVariable.replaceMagicWayIdleLogo.isReplaceable)return; //待替换Logo,右侧标题 const logoDiv = document.querySelector('div.Header_logoContainer__1sCnZ'); const textDiv = document.querySelector('div.Header_title__5Mj8z'); //检测玩家总等级是否加载,以判断游戏主界面是否彻底加载完成 const load_check=document.querySelector('div.Header_totalLevel__8LY3Q'); //完全加载完毕 if (load_check && logoDiv && textDiv &&logoDiv.children.length > 0 && textDiv.children.length > 0&& logoDiv.querySelector('svg')&& textDiv.querySelector('svg')) { let originalLogo = logoDiv.firstChild; const originaltext = textDiv.firstChild; //获取原生魔法Logo const magicLogoHref = document.querySelector('use[href*=".svg#magic"]')?.getAttribute('href'); if(magicLogoHref){ //替换Logo originalLogo.querySelector('use')?.setAttribute('href',magicLogoHref); //替换右侧标题 const newtext = document.createElement('img'); newtext.src = global_url_config.recource.MAGIC_WAY_IDLE_TITLE; newtext.width = '64'; newtext.height = '64'; originaltext.parentNode.replaceChild(newtext, originaltext); globalVariable.replaceMagicWayIdleLogo.isReplaceable=false; } } } // 死亡报警 function notifyDeath(obj){ if (obj && obj.type === "new_battle"){ //战斗人员信息初始化 if(globalVariable.deathNotify.isBattleBegin){ globalVariable.deathNotify.isBattleBegin=false; globalVariable.deathNotify.battleMembers={}; for(const key in obj.players){ globalVariable.deathNotify.battleMembers[key]={ name:obj.players[key].character.name, isalive:true }; } } for(const key in obj.players){ if(obj.players[key].isActive){ globalVariable.deathNotify.battleMembers[key].isalive=true; }else{ if(globalVariable.deathNotify.battleMembers[key].isalive){ showNotification(`${globalVariable.deathNotify.battleMembers[key].name}死了`); } globalVariable.deathNotify.battleMembers[key].isalive=false; } } }else if (obj && obj.type === "battle_updated") { if(obj.pMap){ for (const key in obj.pMap) { if(obj.pMap[key].cHP==0){ if(globalVariable.deathNotify.battleMembers[key].isalive){ globalVariable.deathNotify.battleMembers[key].isalive=false; showNotification(`${globalVariable.deathNotify.battleMembers[key].name}死了`); } }else{ if(globalVariable.deathNotify.battleMembers[key].isalive!==undefined)globalVariable.deathNotify.battleMembers[key].isalive=true; } } } } } // 强制刷新市场价格 function marketPriceUpdate(obj){ let itemDetailMap=globalVariable.gameRawData.initClientData.itemDetailMap; let itemName=itemDetailMap[obj.marketItemOrderBooks.itemHrid].name; let ask=-1; let bid=-1; //读取ask最低报价 if(obj.marketItemOrderBooks.orderBooks[0].asks && obj.marketItemOrderBooks.orderBooks[0].asks.length>0){ ask=obj.marketItemOrderBooks.orderBooks[0].asks[0].price; } //读取bid最高报价 if(obj.marketItemOrderBooks.orderBooks[0].bids && obj.marketItemOrderBooks.orderBooks[0].bids.length>0){ bid=obj.marketItemOrderBooks.orderBooks[0].bids[0].price; } //读取所有物品价格 let jsonObj = JSON.parse(localStorage.getItem("MWITools_marketAPI_json")); //修改当前查看物品价格 if(jsonObj.market[itemName]){ jsonObj.market[itemName].ask=ask; jsonObj.market[itemName].bid=bid; } //将修改后结果写回marketAPI缓存,完成对marketAPI价格的强制修改 localStorage.setItem("MWITools_marketAPI_json", JSON.stringify(jsonObj)); } // 任务排序 // Source: MWI TaskManager 0.2 // Author:微信群 shykai // 任务排序:主函数 => 任务自动排序/显示任务价值 function autoClickTaskManager() { const isInTask = document.querySelector("div.TasksPanel_taskSlotCount__nfhgS"); const isAllTaskAdd = document.querySelector("div.TasksPanel_taskList__2xh4k"); const isIndexAdd = document.querySelector("span.script_taskMapIndex"); if (isInTask){ //进入任务界面 if(isAllTaskAdd&&globalVariable.task.isTaskSortable&&isIndexAdd){ globalVariable.task.isTaskSortable=false; const list = document.querySelector("div.TasksPanel_taskList__2xh4k"); const nodes = [...list.querySelectorAll("div.RandomTask_randomTask__3B9fA")]; if(settingsMap.taskSorting.isTrue)nodes.sort(compareFn).forEach(node => list.appendChild(node)); //依赖满足计算收益 if(settingsMap.taskValue.isTrue && globalVariable.dependency.isInstallEdibleTools){ function convertKEndStringToNumber(str) { if (str.endsWith('K')||str.endsWith('k')) { return Number(str.slice(0, -1)) * 1000; } else { return Number(str); } } let tokenValue=Number(getTaskTokenValue()); nodes.forEach(function (node) { let reward=node.querySelector("div.RandomTask_rewards__YZk7D"); let coin=convertKEndStringToNumber(reward.querySelectorAll("div.Item_count__1HVvv")[0].innerText); let token=Number(reward.querySelectorAll("div.Item_count__1HVvv")[1].innerText); let newDiv = document.createElement("div"); newDiv.textContent = "期望收益: "+(addCommasToNumber((coin+token*tokenValue).toFixed(0))); newDiv.style.color = 'gold'; node.querySelector("div.RandomTask_action__3eC6o").appendChild(newDiv); }); } } }else{ //其他界面或没加载按钮 globalVariable.task.isTaskSortable=true; } } // 支持修改版汉化插件 function getOriTextFromElement(elem) { if (!elem) { //console.error("getTextFromElement null elem"); return ""; } const translatedfrom = elem.getAttribute("script_translatedfrom"); if (translatedfrom) { return translatedfrom; } return elem.textContent; } // 兼容MWITools地图编号 function getMapIndexFromElement(elem) { var node = elem.querySelector("span.script_taskMapIndex"); if (!node) { return -1; } return Number(node.textContent.replace(/\D/ig, "")); } // 任务排序:任务名称 => 该任务类型序号 function getTaskOrderIndexByTaskName(taskName) { var taskType = -1; if (/^(Defeat)( [\S ]+)$/.test(taskName)) { //使战斗任务始终处于其他任务后面 taskType = globalVariable.task.taskBattleIndex; } else if (/^(.+) - .+$/.test(taskName)) { let res = /^(.+) - .+$/.exec(taskName); if (res[1] in globalVariable.task.taskOrderIndex) { taskType = globalVariable.task.taskOrderIndex[res[1]]; } } //if (taskType == -1) console.log(taskName, taskType); return taskType; } // 任务排序:比较A, B任务顺序 function compareFn(a, b) { var a_name = getOriTextFromElement(a.querySelector("div.RandomTask_name__1hl1b")); var b_name = getOriTextFromElement(b.querySelector("div.RandomTask_name__1hl1b")); var a_index = getTaskOrderIndexByTaskName(a_name); var b_index = getTaskOrderIndexByTaskName(b_name); if (a_index === globalVariable.task.taskBattleIndex && b_index === globalVariable.task.taskBattleIndex) { var a_MapIndex = getMapIndexFromElement(a); var b_MapIndex = getMapIndexFromElement(b); if (a_MapIndex != b_MapIndex) { return (a_MapIndex > b_MapIndex ? 1 : -1); } } if (a_index == b_index) { return a_name == b_name ? 0 : (a_name > b_name ? 1 : -1); } return a_index > b_index ? 1 : -1; } // 任务价值:给任务价值数值千分位打逗号 function addCommasToNumber(number) { return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } // 任务价值:计算单个任务代币价值 function getTaskTokenValue(){ if(!globalVariable.dependency.isInstallEdibleTools)return -1; //读取食用工具缓存,计算代币价值 let obj=JSON.parse(localStorage.getItem("Edible_Tools")); //1代币价值 = 1/30陨石箱子 + 1/50牛紫的礼物 let value=obj.Chest_Drop_Data["Large Meteorite Cache"].期望产出Bid/30.0+obj.Chest_Drop_Data["Purple's Gift"].期望产出Bid/50.0; return value; } //战斗排行 function addRankButton() { const waitForNavi = () => { const targetNode = document.querySelector("div.NavigationBar_minorNavigationLinks__dbxh7"); // 确认这个选择器是否适合你的环境 const navigationLinks = document.querySelectorAll('div.NavigationBar_minorNavigationLink__31K7Y'); let toolLink; for (let link of navigationLinks) { if (link.textContent.includes('插件设置')||link.textContent.includes('Script settings')) { toolLink = link; break; } } if (targetNode&&toolLink) { let statsButton = document.createElement("div"); statsButton.setAttribute("class", "NavigationBar_minorNavigationLink__31K7Y"); statsButton.style.color = toolLink.style.color; statsButton.innerHTML = "战斗排行榜"; statsButton.addEventListener("click", () => { window.open("http://www.ratatatata.ip-ddns.com:43967/cnxp.php", "_blank"); }); // 将按钮添加到目标节点 targetNode.insertBefore(statsButton, toolLink.nextSibling); } else { setTimeout(addRankButton, 200); } }; waitForNavi(); // 开始等待目标节点出现 } //组队情况 function addPartyButton() { const waitForNavi = () => { const targetNode = document.querySelector("div.NavigationBar_minorNavigationLinks__dbxh7"); // 确认这个选择器是否适合你的环境 const navigationLinks = document.querySelectorAll('div.NavigationBar_minorNavigationLink__31K7Y'); let toolLink; for (let link of navigationLinks) { if (link.textContent.includes('插件设置')||link.textContent.includes('Script settings')) { toolLink = link; break; } } if (targetNode&&toolLink) { let statsButton = document.createElement("div"); statsButton.setAttribute("class", "NavigationBar_minorNavigationLink__31K7Y"); statsButton.style.color = toolLink.style.color; statsButton.innerHTML = "国人组队情况"; statsButton.addEventListener("click", () => { window.open("http://www.ratatatata.ip-ddns.com:43967/cnparty.php", "_blank"); }); // 将按钮添加到目标节点 targetNode.insertBefore(statsButton, toolLink.nextSibling); } else { setTimeout(addPartyButton, 200); } }; waitForNavi(); // 开始等待目标节点出现 } //追踪设置,添加头像设置栏 function addQQshowButton() { const targetNode = document.querySelector("div.SettingsPanel_infoGrid__2nh1u"); const isqqshowFlagExist = document.querySelector("div.qqshow"); if(targetNode&&!isqqshowFlagExist){ const nameColor=targetNode.querySelectorAll("div.SettingsPanel_value__2nsKD")[2]; let qqshowtitlediv = document.createElement("div"); let qqshowdiv = document.createElement("div"); let qqshowdivflag = document.createElement("div"); qqshowtitlediv.setAttribute("class", "SettingsPanel_label__24LRD"); qqshowtitlediv.innerHTML="更新QQ秀"; qqshowdiv.setAttribute("class", "SettingsPanel_value__2nsKD"); qqshowdiv.style=nameColor.style; qqshowdivflag.setAttribute("class", "qqshow"); let qqshowURLInput = document.createElement("input"); qqshowURLInput.type = "text"; qqshowURLInput.setAttribute("class", "qqshowURLInput"); qqshowURLInput.placeholder = "图床url/提交空白视为删除"; let qqshowSubmitButton = document.createElement("button"); qqshowSubmitButton.setAttribute("class", "Button_button__1Fe9z"); qqshowSubmitButton.textContent = "提交"; qqshowSubmitButton.addEventListener("click", qqshowSubmit); qqshowdiv.appendChild(qqshowdivflag); qqshowdiv.appendChild(qqshowURLInput); qqshowdiv.appendChild(qqshowSubmitButton); let readmetitlediv = document.createElement("div"); let readme = document.createElement("div"); readmetitlediv.setAttribute("class", "SettingsPanel_label__24LRD"); readme.setAttribute("class", "SettingsPanel_value__2nsKD"); readme.innerHTML="先去tupian.li等图床上传图片,再提交url。
直接提交空白将删除QQ秀。刷新后生效。" nameColor.parentNode.insertBefore(readme, nameColor.nextSibling); nameColor.parentNode.insertBefore(readmetitlediv, nameColor.nextSibling); nameColor.parentNode.insertBefore(qqshowdiv, nameColor.nextSibling); nameColor.parentNode.insertBefore(qqshowtitlediv, nameColor.nextSibling); } } function qqshowSubmit(){ let qqshowURLInput=document.querySelector("input.qqshowURLInput"); let url=qqshowURLInput.value function isValidURL(str) { try { new URL(str); return true; } catch (err) { return false; } } if(url==''){ showToast("已删除,刷新生效"); localStorage.setItem("MWIQQshow_timestamp",0); updateqqshow(url); }else if(isValidURL(url)){ showToast("已提交,刷新生效"); localStorage.setItem("MWIQQshow_timestamp",0); updateqqshow(url); }else{ showToast("url不合法"); } } //更新QQ秀 function updateqqshow(face_url){ if (document.URL.includes("test.milkywayidle.com"))return; if (globalVariable.qqShow.characterName == "" || typeof globalVariable.qqShow.characterName === "undefined") { showToast("非法更新,请刷新页面"); return; } const postData = { [globalVariable.qqShow.characterName]: face_url }; return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: global_url_config.magic_api.QQ_SHOW, headers: { "Content-Type": "application/json" }, data:JSON.stringify(postData), onload: function (response) { console.log("请求成功,响应状态码: ", response.status); console.log("响应内容: ", response.responseText); resolve(); }, onerror: function (error) { console.error('QQ秀更新出错:', error); reject(error); } }); }); } //获取所有玩家QQ秀图片链接 function getQQShowData(){ return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'GET', url: global_url_config.magic_api.QQ_SHOW, headers: { "Content-Type": "application/json" }, onload: function (response) { try { const data = JSON.parse(response.responseText); globalVariable.qqShow.replacementTargets=data; localStorage.setItem("magic_qqshow_cache_timestamp", Date.now()); localStorage.setItem("magic_qqshow_cache",JSON.stringify(globalVariable.qqShow.replacementTargets)); resolve(); } catch (jsonError) { console.error('Error parsing JSON:', jsonError); reject(jsonError); } }, onerror: function (error) { console.error('获取失败:', error); reject(error); } }); }); } // Source: MWI玩家图标替换 // Author: Ak4r1 ChatGpt Stella bot7420 function replaceIconsIn(node) { const iconElements = node.querySelectorAll(`div.FullAvatar_fullAvatar__3RB2h`); for (const elem of iconElements) { if (elem.closest("div.CowbellStorePanel_avatarsTab__1nnOY")) { continue; // 商店页面 } const playerId = findPlayerIdByAvatarElem(elem); if (!playerId) { //console.error("ICONS: replaceIconsIn can't find playerId"); //设置页面下面两个小人会引发异常,不要大惊小怪 //console.log(elem); continue; // 找不到 playerId } if (!globalVariable.qqShow.replacementTargets.hasOwnProperty(playerId)) { continue; // 没有配置图片地址 } const newImgElement = document.createElement("img"); newImgElement.src = globalVariable.qqShow.replacementTargets[playerId]; newImgElement.style.width = "100%"; newImgElement.style.height = "auto"; elem.innerHTML = ""; elem.appendChild(newImgElement); } } function findPlayerIdByAvatarElem(avatarElem) { // Profile 窗口页 const profilePageDiv = avatarElem.closest("div.SharableProfile_modal__2OmCQ"); if (profilePageDiv) { return profilePageDiv.querySelector(".CharacterName_name__1amXp")?.textContent.trim(); } // 网页右上角 const headerDiv = avatarElem.closest("div.Header_header__1DxsV"); if (headerDiv) { return headerDiv.querySelector(".CharacterName_name__1amXp")?.textContent.trim(); } // 战斗页面 const combatDiv = avatarElem.closest("div.CombatUnit_combatUnit__1m3XT"); if (combatDiv) { return combatDiv.querySelector(".CombatUnit_name__1SlO1")?.textContent.trim(); } // 组队页面 const partyDiv = avatarElem.closest("div.Party_partySlot__1xuiq"); if (partyDiv) { return partyDiv.querySelector(".CharacterName_name__1amXp")?.textContent.trim(); } return null; } //初始化观察者,分配替换目标 function initQQShowObserver(){ globalVariable.qqShow.observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if ( node.tagName === "DIV" && !node.classList.contains("ProgressBar_innerBar__3Z_sf") && !node.classList.contains("CountdownOverlay_countdownOverlay__2QRmL") && !node.classList.contains("ChatMessage_chatMessage__2wev4") && !node.classList.contains("Header_loot__18Cbe") && !node.classList.contains("script_itemLevel") && !node.classList.contains("script_key") && !node.classList.contains("dps-info") && !node.classList.contains("MuiTooltip-popper") ) { replaceIconsIn(node); } }); }); }); } // 显示提醒 // showToast() // Source: **助手 // Author: Trutn_Light Stella const toastQueues = Array.from({ length: 5 }, () => []); const maxVisibleToasts = Math.floor(window.innerHeight / 2 / 50); let isToastVisible = Array(5).fill(false); function displayNextToast(queueIndex) { if (isToastVisible[queueIndex] || toastQueues[queueIndex].length === 0) return; const { message, duration } = toastQueues[queueIndex].shift(); isToastVisible[queueIndex] = true; const toast = createToastElement(message, queueIndex); toast.style.opacity = '0'; requestAnimationFrame(() => { toast.style.opacity = '1'; }); setTimeout(() => { toast.style.opacity = '0'; setTimeout(() => { document.body.removeChild(toast); isToastVisible[queueIndex] = false; displayNextToast(queueIndex); }, 500); }, duration); } function showToast(message, duration = 2000) { const queueIndex = toastQueues.findIndex(queue => queue.length < maxVisibleToasts); if (queueIndex === -1) return; toastQueues[queueIndex].push({ message, duration }); displayNextToast(queueIndex); } function createToastElement(message, queueIndex) { const toast = document.createElement('div'); toast.className = 'toast'; toast.style.position = 'fixed'; toast.style.bottom = `${20 + queueIndex * 60}px`; toast.style.left = '50%'; toast.style.transform = 'translateX(-50%)'; toast.style.backgroundColor = '#333'; toast.style.color = '#fff'; toast.style.padding = '10px 20px'; toast.style.borderRadius = '5px'; toast.style.zIndex = '1000'; toast.style.textAlign = 'center'; toast.style.transition = 'opacity 0.5s'; toast.textContent = message; document.body.appendChild(toast); return toast; } //显示冻结资金 function showMarketFreezeFunds(){ const targetNode = document.querySelector("div.MarketplacePanel_coinStack__1l0UD"); //const isFreezeFundsExist = document.querySelector("div.FreezeFundsFlag"); if(targetNode){ if(globalVariable.market.freezeFundsUpdateFlag){ const isFreezeFundsExist= document.querySelector("div.FreezeFunds"); if (isFreezeFundsExist) { isFreezeFundsExist.parentNode.removeChild(isFreezeFundsExist); } let freezeFunds = targetNode.cloneNode(true); const countNode = freezeFunds.querySelector("div.Item_count__1HVvv"); const textNode = freezeFunds.querySelector("div.Item_name__2C42x"); if (countNode)countNode.textContent = formatCoinValue(globalVariable.market.freezeFundsValue); if (textNode)textNode.textContent = "冻结资金"; freezeFunds.style.left = "110px"; freezeFunds.classList.add("FreezeFunds"); targetNode.parentNode.insertBefore(freezeFunds, targetNode.nextSibling); globalVariable.market.freezeFundsUpdateFlag=false; //console.log("#######",calculateALLFunds()); } } } //转换冻结资金数值格式,大于10B后显示B级数 // 123456 => 123.4K // 12345678 => 12.3M function formatCoinValue(num) { if (num >= 1e10) { return (num / 1e9).toFixed(1) + "B"; } else if (num >= 1e6) { return (num / 1e6).toFixed(1) + "M"; } else if (num >= 1e3) { return (num / 1e3).toFixed(1) + "K"; } return num.toString(); }; function calculateMarketFreezeFunds(ini_marketListings){ let networth=0; for (const item of ini_marketListings) { const quantity = item.orderQuantity - item.filledQuantity; if (!item.isSell) { networth+=quantity * item.price; } } globalVariable.market.freezeFundsUpdateFlag=true; return networth; } function updateMarketFreezeFunds(obj){ obj.endMarketListings.forEach((item) => { if(!item.isSell){ const quantity = item.orderQuantity - item.filledQuantity; if(item.status=="/market_listing_status/active"){ if(item.filledQuantity==0&&item.unclaimedItemCount==0){ //主动挂单 globalVariable.market.freezeFundsValue+=quantity*item.price; }else if(item.unclaimedItemCount>0){ //被动撤单(成功买进) globalVariable.market.freezeFundsValue-=item.unclaimedItemCount*item.price; } }else if(item.status=="/market_listing_status/cancelled"){ //主动撤单 globalVariable.market.freezeFundsValue-=quantity*item.price; } globalVariable.market.freezeFundsUpdateFlag=true; } }); } function fixMWIToolsUIStyle(){ const allButtons = document.getElementsByTagName('button'); for (const button of allButtons){ if (button.innerText == "导出人物到剪贴板") { button.style.backgroundColor = '#4357AF'; button.style.color = 'white'; } } const buildScoresDiv = document.getElementById('toggleScores_profile'); if (buildScoresDiv) { const allChildren = buildScoresDiv.parentNode.querySelectorAll('*'); allChildren.forEach(function (element) { element.style.color = '#E7E7E7'; element.style.fontWeight = ''; element.style.fontSize = '16px'; }); } const sortByAskButton = document.getElementById('script_sortByAsk_btn'); if(sortByAskButton){ sortByAskButton.style.backgroundColor = '#4357AF'; sortByAskButton.style.color = 'white'; sortByAskButton.style.boxShadow = "none"; sortByAskButton.style.border = "0px"; sortByAskButton.style.padding = "6px"; sortByAskButton.style.minWidth = '55px'; } const sortByBidButton = document.getElementById('script_sortByBid_btn'); if(sortByBidButton){ sortByBidButton.style.backgroundColor = '#4357AF'; sortByBidButton.style.color = 'white'; sortByBidButton.style.boxShadow = "none"; sortByBidButton.style.border = "0px"; sortByBidButton.style.padding = "6px"; sortByBidButton.style.minWidth = '55px'; } const sortByNoneButton = document.getElementById('script_sortByNone_btn'); if(sortByNoneButton){ sortByNoneButton.style.backgroundColor = '#4357AF'; sortByNoneButton.style.color = 'white'; sortByNoneButton.style.boxShadow = "none"; sortByNoneButton.style.border = "0px"; sortByNoneButton.style.padding = "6px"; sortByNoneButton.style.minWidth = '55px'; } const itemSortDiv = document.getElementById('script_sortByNone_btn')?.parentNode; if(itemSortDiv){ itemSortDiv.style.color = '#E7E7E7'; } } function uploadProfileShared(obj){ if (document.URL.includes("test.milkywayidle.com"))return; return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: global_url_config.magic_api.PROFILE_SHARED_UPLOAD, headers: { "Content-Type": "application/json" }, data:JSON.stringify(obj), onload: function (response) { resolve(); }, onerror: function (error) { reject(error); } }); }); } function uploadInitCharacterData(obj){ const fake_profile_shared={} fake_profile_shared.type="profile_shared"; fake_profile_shared.profile={}; fake_profile_shared.profile.characterSkills=obj.characterSkills; fake_profile_shared.profile.combatLevel=obj.combatUnit.combatDetails.combatLevel; if(obj.guild){ fake_profile_shared.profile.guildName=obj.guild.name; fake_profile_shared.profile.guildRole=obj.guildCharacterMap[obj.character.id].role; }else{ fake_profile_shared.profile.guildName=""; fake_profile_shared.profile.guildRole=""; } fake_profile_shared.profile.sharableCharacter=obj.character; fake_profile_shared.profile.wearableItemMap={} obj.characterItems.forEach(item=>{ if(item.itemLocationHrid!='/item_locations/inventory'){ fake_profile_shared.profile.wearableItemMap[item.itemLocationHrid]=item; } }) uploadProfileShared(fake_profile_shared); uploadPartyInfo(obj); registerCharacter(fake_profile_shared); } function uploadPartyInfo(obj){ if (document.URL.includes("test.milkywayidle.com"))return; const party_info={}; party_info.reporter=obj.character.id; party_info.is_battle=false; if(obj.partyInfo){ party_info.is_battle=true; party_info.partyInfo=obj.partyInfo; } return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: global_url_config.magic_api.PARTY_INFO, headers: { "Content-Type": "application/json" }, data:JSON.stringify(party_info), onload: function (response) { resolve(); }, onerror: function (error) { reject(error); } }); }); } function registerCharacter(obj){ if (document.URL.includes("test.milkywayidle.com"))return; let characterName=obj.profile.sharableCharacter.name; GM_setValue("magic_register_character",characterName); return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: global_url_config.magic_api.REGISTERCHARACTER, headers: { "Content-Type": "application/json" }, data:JSON.stringify(obj), onload: function (response) { resolve(); }, onerror: function (error) { reject(error); } }); }); } //修改神圣奶酪系列道具图标 function replaceHolyItemIcon(){ const holySvgs = document.querySelectorAll('svg:has(use[href*="holy"])'); holySvgs.forEach(svg => { const useElement = svg.querySelector('use'); if (useElement) { const oldHref = useElement.getAttribute('href'); if (oldHref&&oldHref.startsWith("/static")&& oldHref.indexOf("#holy_cow") === -1) { const item_name=oldHref.split('#')[1]; const targetSymbolElement = globalVariable.gameRawData.oldHolySvgDOM.querySelector(`symbol[id="${item_name}"]`); //成功找到替换目标 if(targetSymbolElement){ //svg.removeChild(svg.firstChild); //与MWITools右上角显示等级功能冲突,故增加无效use标签,用于MWITools装备识别 useElement.setAttribute('href','#'+item_name); const newSvgElement = document.createElementNS('http://www.w3.org/2000/svg','svg'); svg.appendChild(newSvgElement); const children = targetSymbolElement.childNodes; for (let i = 0; i < children.length; i++) { newSvgElement.appendChild(children[i].cloneNode(true)); } newSvgElement.setAttribute('viewBox',targetSymbolElement.getAttribute('viewBox')); newSvgElement.setAttribute('fill','none'); } } } }); } //加载老Holy SVG到DOM function loadOldHolySvg(){ const parser = new DOMParser(); globalVariable.gameRawData.oldHolySvgDOM = parser.parseFromString(global_url_config.recource.HOLY_ITEM_BACKUP, 'application/xml'); } //other //工具函数:发送弹窗 => 死亡报警 function showNotification(textToPrint){ let notification = new Notification('Magic Way Idle', { body: textToPrint, }); } //工具函数:cookie检测 => 登录检测 function checkCookieExists(cookieName) { const cookies = document.cookie.split(';'); for (const cookie of cookies) { const trimmedCookie = cookie.trim(); if (trimmedCookie.startsWith(cookieName + "=")) { return true; } } return false; } //工具函数:市场API => (暂未使用) async function fetchMarketJSON(forceFetch = false) { let sendRequest = GM.xmlHttpRequest || GM_xmlhttpRequest; if (typeof sendRequest != 'function') { //console.error("fetchMarketJSON null function"); globalVariable.market.isUsingLocalMarketBackup = true; const jsonStr = global_url_config.market.LOCAL_BACKUP; const jsonObj = JSON.parse(jsonStr); if (jsonObj && jsonObj.time && jsonObj.market) { jsonObj.market.Coin.ask = 1; jsonObj.market.Coin.bid = 1; //console.log(jsonObj); localStorage.setItem("MWITools_marketAPI_timestamp", Date.now()); localStorage.setItem("MWITools_marketAPI_json", JSON.stringify(jsonObj)); return jsonObj; } } if ( !forceFetch && localStorage.getItem("MWITools_marketAPI_timestamp") && Date.now() - localStorage.getItem("MWITools_marketAPI_timestamp") < 900000 ) { return JSON.parse(localStorage.getItem("MWITools_marketAPI_json")); } //console.log("fetchMarketJSON fetch github start"); let jsonStr = null; jsonStr = await new Promise((resolve, reject) => { sendRequest({ url: global_url_config.market.API_URL, method: "GET", synchronous: true, timeout: 5000, onload: async (response) => { if (response.status == 200) { //console.log("fetchMarketJSON fetch github success 200"); resolve(response.responseText); } else { //console.error("fetchMarketJSON fetch github onload with HTTP status failure " + response.status); resolve(null); } }, onabort: () => { //console.error("fetchMarketJSON fetch github onabort"); resolve(null); }, onerror: () => { //console.error("fetchMarketJSON fetch github onerror"); resolve(null); }, ontimeout: () => { //console.error("fetchMarketJSON fetch github ontimeout"); resolve(null); }, }); }); if (jsonStr === null) { //console.log("fetchMarketJSON fetch backup start"); jsonStr = await new Promise((resolve, reject) => { sendRequest({ url: global_url_config.market.API_URL_BACKUP, method: "GET", synchronous: true, timeout: 5000, onload: async (response) => { if (response.status == 200) { //console.log("fetchMarketJSON fetch backup success 200"); resolve(response.responseText); } else { //console.error("fetchMarketJSON fetch backup onload with HTTP status failure " + response.status); resolve(null); } }, onabort: () => { //console.error("fetchMarketJSON fetch backup onabort"); resolve(null); }, onerror: () => { //console.error("fetchMarketJSON fetch backup onerror"); resolve(null); }, ontimeout: () => { console.error("fetchMarketJSON fetch backup ontimeout"); resolve(null); }, }); }); } if (!jsonStr) { //console.error("fetchMarketJSON network error, using local version"); globalVariable.market.isUsingLocalMarketBackup = true; jsonStr = global_url_config.market.LOCAL_BACKUP; } else { globalVariable.market.isUsingLocalMarketBackup = false; } const jsonObj = JSON.parse(jsonStr); if (jsonObj && jsonObj.time && jsonObj.market) { jsonObj.market.Coin.ask = 1; jsonObj.market.Coin.bid = 1; //console.log(jsonObj); localStorage.setItem("MWITools_marketAPI_timestamp", Date.now()); localStorage.setItem("MWITools_marketAPI_json", JSON.stringify(jsonObj)); return jsonObj; } //console.error("MWITools: fetchMarketJSON JSON.parse error"); localStorage.setItem("MWITools_marketAPI_timestamp", 0); localStorage.setItem("MWITools_marketAPI_json", ""); return null; } })();