点击每个 JavaScript 画布

问题描述 投票:0回答:1

我尝试使用“imakro”(firefox 的插件)来实现自动化。 该插件可以记录(和播放)网站上的点击,到目前为止效果良好。 这个网站有 2 个画布元素,我必须点击才能实现自动化,但 5 个记录选项中没有一个可以记录此点击。

Picture

Imakro 代码如下所示:

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(16)>DIV:nth-of-type(6)>DIV:nth-of-type(3)" BUTTON=0

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(11)>DIV>DIV>DIV:nth-of-type(3)>DIV:nth-of-type(2)" BUTTON=0

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(11)>DIV>DIV>DIV:nth-of-type(6)>A" BUTTON=0

到目前为止我最好的想法是: Imakro 可以对每个 urlbox 执行 javascript,所以如果我可以点击每个 url 的画布,我的问题就会消失:

URL GOTO=javascript:document.body.contentEditable='true';<SP>document.designMode='on';<SP>void<SP>0

网站:http://orteil.dashnet.org/cookieclicker/ (使用这个让2个画布出现在左下角)=>“选项”=>“输入保存”并将此代码提供给框:

Mi4wMDJ8fDE0ODA5NDczNzQ1NDU7MTQ3NjM2MjczNjIwNDsxNDgxMDA4Nzg3OTcwO015cm9zfMOnwq3CoAR8OC43MDg0MDYxMDQxMzEyNjNlKzI2OzIuMjk2NTY4NjkyMDQ2ODM2M2UrMjc7MTIyOzMxMjY7Mi44MzM0MjM4OTMwMjA4NjM2ZSsyNjs2ODQwOzA7MTs1LjgzMTI2NzM4MDE4NTU2NGUrMjk7MzswOzA7MDstMTsyMjsyNzsxLjIzOTc4MTkwOTU1MzI4MzZlKzI2OzIwOzA7Njs3NTUzMDI7MjtjaHJpc3RtYXM7OC41MTc1OTc4MTA2MDgyMTllKzI2OzEwOzgzNTQ1MTszODc3NDs3OTY2Nzc7MDswOzE4OTszMDY7MzIxOy0xOy0xOzQ7MDswOzA7MDswOzA7fDM1MiwzNTIsMS4wNzg4OTQyNjU3MTU4MDA0ZSsyNSwwOzM3OCwzNzgsOC43NjkwMjE4MTgzMDc0MTZlKzIyLDA7MzMyLDMzMiw5LjM0NDk2OTY1Mjk3NDEwM2UrMjIsMDsyODgsMjg4LDIuNDQ1MTg3NDM4NTAyMTQ1NmUrMjMsMDsyNzUsMjc1LDguNTY5NDQyNjcyMjUyODI1ZSsyMywwOzI1OCwyNTgsMy4wNDI1MzIxODQ2OTg5MDZlKzIzLDA7MjcwLDI3MCwxLjQ4OTQ3NjE0NTU2MTg1OTJlKzI0LDA7MjMzLDIzMyw2LjE4MTk1MzIxODU4NTE4M2UrMjMsMDsyMDIsMjAyLDIuNjkwMTAxMzA1ODc1OTkwNmUrMjMsMDsxOTYsMTk2LDguMTkxMzEyMjMzNjc1OTI0ZSsyMywwOzE5MiwxOTIsNS45NjY4NTEzMzY1MTEzODNlKzI0LDA7MTkyLDE5MiwyLjcyNTE5Nzk4ODAyMzk3MzdlKzI1LDA7MTgyLDE4MiwxLjg2NDgyMjUxODQyNTk1MjZlKzI1LDA7MTgwLDE4MCwzLjA3MDE4NjY3NjI1Mzk1NTJlKzI2LDA7fMOnwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cr8OnwrPCvMOkwozCv8Okwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cs8Onwr/Cv8OnwoDCgMOkwrDCsMOnwr/CvMOkwoDCg8OkwoDCgMOkwr/Cv8Onwr/Cv8OnwqrCj8Onwr/Cv8Onwr/Cv8Onwr/CssOkwoDCgMOkwoDCgMOkwoDCg8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8Onwr/Cv8OnwoDCgMOkwr/Cv8Okwr/CvMOkwr/CvMOnwr/Cv8OnwoDCj8Onwr/CsMOkwoDCj8OmwrzCv8OkwojCr8Okwo/Cv8Onwr/Cv8Onwr/Cv8OnwrPCr8Okwo/Cj8Onwr/Cv8Onwr/Cv8Onwr/Cv8Ohwr/CsHzDp8K/wr/Dp8K/wr/Dp8K/wr/Dp8K/wr/Dp8K/wr/DpcK/wr/DpsK/wrzDpMK/wr/Dp8K/wr/Dp8K/wr/Dp8K/wr/Dp8K/wrvDp8K/wr/Dp8K/wr/Dp8K/wrPDp8K/wrPDp8KBwr/Dp8K3wpvDp8K4wo8%3D%21END%21

谢谢你的帮助

格里兹反

编辑1:
我的目的不是制作一个自动播放器,我的目的是制作一个购买建筑物和升级的自动播放器,并且两者都工作得很好。

编辑2:
我尝试了

$('#backgroundLeftCanvas').click()
,但它说
undefined
$('#backgroundLeftCanvas')
回馈
<canvas id="backgroundLeftCanvas" style="z-index:5;" width="482" height="582">

编辑3:
我认为我有正确的东西:

$('#specialPopup')
。它返回
<div id="specialPopup" class="framed prompt offScreen">

编辑4:
我现在有一个有趣的弹出窗口,里面什么也没有。(参见链接)我在屏幕外编辑了屏幕上的内容。我怎样才能用正确的东西做到这一点?

(我无法正常发布链接,声誉错误)

i.stac

k.im

gur.com/Tl

SIs.png

编辑5:
我现在可以让弹出窗口消失:

Game.ToggleSpecialMenu(0);

我尝试过

Game.ToggleSpecialMenu(1);
但这会创建一个不会消失的弹出窗口,即使我单击X

编辑6:

我想我已经找到了一些东西,但我仍然不工作

if (Game.Has('A festive hat')) Game.specialTabs.push('santa');
if (Game.Has('A crumbly egg')) Game.specialTabs.push('dragon');
if (Game.specialTabs.length==0) {Game.ToggleSpecialMenu(0);return;}

编辑7: 我认为解决方案就在这里:
游戏.specialTab=''; Game.specialTabHovered=''; Game.specialTabs=[];

    Game.UpdateSpecial=function()
    {
        Game.specialTabs=[];
        if (Game.Has('A festive hat')) Game.specialTabs.push('santa');
        if (Game.Has('A crumbly egg')) Game.specialTabs.push('dragon');
        if (Game.specialTabs.length==0) {Game.ToggleSpecialMenu(0);return;}

        if (Game.LeftBackground)
        {
            Game.specialTabHovered='';
            var len=Game.specialTabs.length;
            if (len==0) return;
            var y=Game.LeftBackground.canvas.height-24-48*len;
            for (var i in Game.specialTabs)
            {
                var selected=0;
                if (Game.specialTab==Game.specialTabs[i]) selected=1;
                var x=24;
                var s=1;
                if (selected) {s=2;x+=24;}

                if (Math.abs(Game.mouseX-x)<=24*s && Math.abs(Game.mouseY-y)<=24*s)
                {
                    Game.specialTabHovered=Game.specialTabs[i];
                    Game.mousePointer=1;
                    Game.CanClick=0;
                    if (Game.Click)
                    {
                        if (Game.specialTab!=Game.specialTabs[i]) {Game.specialTab=Game.specialTabs[i];Game.ToggleSpecialMenu(1);PlaySound('snd/press.mp3');}
                        else {Game.ToggleSpecialMenu(0);PlaySound('snd/press.mp3');}
                        //PlaySound('snd/tick.mp3');
                    }
                }

                y+=48;
            }
        }
    }

    Game.santaLevels=['Festive test tube','Festive ornament','Festive wreath','Festive tree','Festive present','Festive elf fetus','Elf toddler','Elfling','Young elf','Bulky elf','Nick','Santa Claus','Elder Santa','True Santa','Final Claus'];
    Game.santaDrops=['Increased merriness','Improved jolliness','A lump of coal','An itchy sweater','Reindeer baking grounds','Weighted sleighs','Ho ho ho-flavored frosting','Season savings','Toy workshop','Naughty list','Santa\'s bottomless bag','Santa\'s helpers','Santa\'s legacy','Santa\'s milk and cookies'];
    for (var i in Game.santaDrops)//scale christmas upgrade prices with santa level
    {Game.Upgrades[Game.santaDrops[i]].priceFunc=function(){return Math.pow(3,Game.santaLevel)*2525;}}

    Game.UpgradeSanta=function()
    {
        var moni=Math.pow(Game.santaLevel+1,Game.santaLevel+1);
        if (Game.cookies>moni && Game.santaLevel<14)
        {
            PlaySound('snd/shimmerClick.mp3');

            Game.Spend(moni);
            Game.santaLevel=(Game.santaLevel+1)%15;
            if (Game.santaLevel==14)
            {
                Game.Unlock('Santa\'s dominion');
                if (Game.prefs.popups) Game.Popup('You are granted<br>Santa\'s dominion.');
                else Game.Notify('You are granted Santa\'s dominion.','',Game.Upgrades['Santa\'s dominion'].icon);
            }
            var drops=[];
            for (var i in Game.santaDrops) {if (!Game.HasUnlocked(Game.santaDrops[i])) drops.push(Game.santaDrops[i]);}
            var drop=choose(drops);
            if (drop)
            {
                Game.Unlock(drop);
                if (Game.prefs.popups) Game.Popup('You find a present which contains...<br>'+drop+'!');
                else Game.Notify('Found a present!','You find a present which contains...<br><b>'+drop+'</b>!',Game.Upgrades[drop].icon);
            }

            Game.ToggleSpecialMenu(1);

            if (l('specialPic')){var rect=l('specialPic').getBoundingClientRect();Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2);}

            if (Game.santaLevel>=6) Game.Win('Coming to town');
            if (Game.santaLevel>=14) Game.Win('All hail Santa');
            Game.recalculateGains=1;
            Game.upgradesToRebuild=1;
        }
    }

    Game.dragonLevels=[
        {name:'Dragon egg',action:'Chip it',pic:0,
            cost:function(){return Game.cookies>=1000000;},
            buy:function(){Game.Spend(1000000);},
            costStr:function(){return Beautify(1000000)+' cookies';}},
        {name:'Dragon egg',action:'Chip it',pic:1,
            cost:function(){return Game.cookies>=1000000*2;},
            buy:function(){Game.Spend(1000000*2);},
            costStr:function(){return Beautify(1000000*2)+' cookies';}},
        {name:'Dragon egg',action:'Chip it',pic:2,
            cost:function(){return Game.cookies>=1000000*4;},
            buy:function(){Game.Spend(1000000*4);},
            costStr:function(){return Beautify(1000000*4)+' cookies';}},
        {name:'Shivering dragon egg',action:'Hatch it',pic:3,
            cost:function(){return Game.cookies>=1000000*8;},
            buy:function(){Game.Spend(1000000*8);},
            costStr:function(){return Beautify(1000000*8)+' cookies';}},
        {name:'Krumblor, cookie hatchling',action:'Train Breath of Milk<br><small>Aura : kittens are 5% more effective</small>',pic:4,
            cost:function(){return Game.cookies>=1000000*16;},
            buy:function(){Game.Spend(1000000*16);},
            costStr:function(){return Beautify(1000000*16)+' cookies';}},
        {name:'Krumblor, cookie hatchling',action:'Train Dragon Cursor<br><small>Aura : clicking is 5% more effective</small>',pic:4,
            cost:function(){return Game.Objects['Cursor'].amount>=100;},
            buy:function(){Game.Objects['Cursor'].sacrifice(100);},
            costStr:function(){return '100 cursors';}},
        {name:'Krumblor, cookie hatchling',action:'Train Elder Battalion<br><small>Aura : grandmas gain +1% CpS for every non-grandma building</small>',pic:4,
            cost:function(){return Game.Objects['Grandma'].amount>=100;},
            buy:function(){Game.Objects['Grandma'].sacrifice(100);},
            costStr:function(){return '100 grandmas';}},
        {name:'Krumblor, cookie hatchling',action:'Train Reaper of Fields<br><small>Aura : golden cookies may trigger a Dragon Harvest</small>',pic:4,
            cost:function(){return Game.Objects['Farm'].amount>=100;},
            buy:function(){Game.Objects['Farm'].sacrifice(100);},
            costStr:function(){return '100 farms';}},
        {name:'Krumblor, cookie dragon',action:'Train Earth Shatterer<br><small>Aura : buildings sell back for 85% instead of 50%</small>',pic:5,
            cost:function(){return Game.Objects['Mine'].amount>=100;},
            buy:function(){Game.Objects['Mine'].sacrifice(100);},
            costStr:function(){return '100 mines';}},
        {name:'Krumblor, cookie dragon',action:'Train Master of the Armory<br><small>Aura : all upgrades are 2% cheaper</small>',pic:5,
            cost:function(){return Game.Objects['Factory'].amount>=100;},
            buy:function(){Game.Objects['Factory'].sacrifice(100);},
            costStr:function(){return '100 factories';}},
        {name:'Krumblor, cookie dragon',action:'Train Fierce Hoarder<br><small>Aura : all buildings are 2% cheaper</small>',pic:5,
            cost:function(){return Game.Objects['Bank'].amount>=100;},
            buy:function(){Game.Objects['Bank'].sacrifice(100);},
            costStr:function(){return '100 banks';}},
        {name:'Krumblor, cookie dragon',action:'Train Dragon God<br><small>Aura : heavenly chips bonus +5%</small>',pic:5,
            cost:function(){return Game.Objects['Temple'].amount>=100;},
            buy:function(){Game.Objects['Temple'].sacrifice(100);},
            costStr:function(){return '100 temples';}},
        {name:'Krumblor, cookie dragon',action:'Train Arcane Aura<br><small>Aura : golden cookies appear 5% more often</small>',pic:5,
            cost:function(){return Game.Objects['Wizard tower'].amount>=100;},
            buy:function(){Game.Objects['Wizard tower'].sacrifice(100);},
            costStr:function(){return '100 wizard towers';}},
        {name:'Krumblor, cookie dragon',action:'Train Dragonflight<br><small>Aura : golden cookies may trigger a Dragonflight</small>',pic:5,
            cost:function(){return Game.Objects['Shipment'].amount>=100;},
            buy:function(){Game.Objects['Shipment'].sacrifice(100);},
            costStr:function(){return '100 shipments';}},
        {name:'Krumblor, cookie dragon',action:'Train Ancestral Metamorphosis<br><small>Aura : golden cookies give 10% more cookies</small>',pic:5,
            cost:function(){return Game.Objects['Alchemy lab'].amount>=100;},
            buy:function(){Game.Objects['Alchemy lab'].sacrifice(100);},
            costStr:function(){return '100 alchemy labs';}},
        {name:'Krumblor, cookie dragon',action:'Train Unholy Dominion<br><small>Aura : wrath cookies give 10% more cookies</small>',pic:5,
            cost:function(){return Game.Objects['Portal'].amount>=100;},
            buy:function(){Game.Objects['Portal'].sacrifice(100);},
            costStr:function(){return '100 portals';}},
        {name:'Krumblor, cookie dragon',action:'Train Epoch Manipulator<br><small>Aura : golden cookie effects last 5% longer</small>',pic:5,
            cost:function(){return Game.Objects['Time machine'].amount>=100;},
            buy:function(){Game.Objects['Time machine'].sacrifice(100);},
            costStr:function(){return '100 time machines';}},
        {name:'Krumblor, cookie dragon',action:'Train Mind Over Matter<br><small>Aura : +25% random drops</small>',pic:5,
            cost:function(){return Game.Objects['Antimatter condenser'].amount>=100;},
            buy:function(){Game.Objects['Antimatter condenser'].sacrifice(100);},
            costStr:function(){return '100 antimatter condensers';}},
        {name:'Krumblor, cookie dragon',action:'Train Radiant Appetite<br><small>Aura : all cookie production multiplied by 2</small>',pic:5,
            cost:function(){return Game.Objects['Prism'].amount>=100;},
            buy:function(){Game.Objects['Prism'].sacrifice(100);},
            costStr:function(){return '100 prisms';}},
        {name:'Krumblor, cookie dragon',action:'Bake dragon cookie<br><small>Delicious!</small>',pic:6,
            cost:function(){var fail=0;for (var i in Game.Objects){if (Game.Objects[i].amount<50) fail=1;}return (fail==0);},
            buy:function(){for (var i in Game.Objects){Game.Objects[i].sacrifice(50);}Game.Unlock('Dragon cookie');},
            costStr:function(){return '50 of every building';}},
        {name:'Krumblor, cookie dragon',action:'Train secondary aura<br><small>Lets you use two dragon auras simultaneously</small>',pic:6,
            cost:function(){var fail=0;for (var i in Game.Objects){if (Game.Objects[i].amount<200) fail=1;}return (fail==0);},
            buy:function(){for (var i in Game.Objects){Game.Objects[i].sacrifice(200);}},
            costStr:function(){return '200 of every building';}},
        {name:'Krumblor, cookie dragon',action:'Your dragon is fully trained.',pic:7}
    ];

    Game.dragonAuras={
        0:{name:'No aura',pic:[0,7],desc:'Select an aura from those your dragon knows.'},
        1:{name:'Breath of Milk',pic:[18,25],desc:'Kittens are <b>5%</b> more effective.'},
        2:{name:'Dragon Cursor',pic:[0,25],desc:'Clicking is <b>5%</b> more effective.'},
        3:{name:'Elder Battalion',pic:[1,25],desc:'Grandmas gain <b>+1% CpS</b> for every non-grandma building.'},
        4:{name:'Reaper of Fields',pic:[2,25],desc:'Golden cookies may trigger a <b>Dragon Harvest</b>.'},
        5:{name:'Earth Shatterer',pic:[3,25],desc:'Buildings sell back for <b>85%</b> instead of 50%.'},
        6:{name:'Master of the Armory',pic:[4,25],desc:'All upgrades are <b>2%</b> cheaper.'},
        7:{name:'Fierce Hoarder',pic:[15,25],desc:'All buildings are <b>2%</b> cheaper.'},
        8:{name:'Dragon God',pic:[16,25],desc:'Prestige CpS bonus <b>+5%</b>.'},
        9:{name:'Arcane Aura',pic:[17,25],desc:'Golden cookies appear <b>+5%</b> more often.'},
        10:{name:'Dragonflight',pic:[5,25],desc:'Golden cookies may trigger a <b>Dragonflight</b>.'},
        11:{name:'Ancestral Metamorphosis',pic:[6,25],desc:'Golden cookies give <b>10%</b> more cookies.'},
        12:{name:'Unholy Dominion',pic:[7,25],desc:'Wrath cookies give <b>10%</b> more cookies.'},
        13:{name:'Epoch Manipulator',pic:[8,25],desc:'Golden cookies last <b>5%</b> longer.'},
        14:{name:'Mind Over Matter',pic:[13,25],desc:'Random drops are <b>25% more common</b>.'},
        15:{name:'Radiant Appetite',pic:[14,25],desc:'All cookie production <b>multiplied by 2</b>.'},
    };

    Game.hasAura=function(what)
    {
        if (Game.dragonAuras[Game.dragonAura].name==what || Game.dragonAuras[Game.dragonAura2].name==what) return true; else return false;
    }

    Game.SelectDragonAura=function(slot,update)
    {   
        var currentAura=0;
        var otherAura=0;
        if (slot==0) currentAura=Game.dragonAura; else currentAura=Game.dragonAura2;
        if (slot==0) otherAura=Game.dragonAura2; else otherAura=Game.dragonAura;
        if (!update) Game.SelectingDragonAura=currentAura;

        var str='';
        for (var i in Game.dragonAuras)
        {
            if (Game.dragonLevel>=parseInt(i)+4)
            {
                var icon=Game.dragonAuras[i].pic;
                if (i==0 || i!=otherAura) str+='<div class="crate enabled'+(i==Game.SelectingDragonAura?' highlighted':'')+'" style="opacity:1;float:none;display:inline-block;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SetDragonAura('+i+','+slot+');" onMouseOut="Game.DescribeDragonAura('+Game.SelectingDragonAura+');" onMouseOver="Game.DescribeDragonAura('+i+');"'+
                '></div>';
            }
        }

        var highestBuilding=0;
        for (var i in Game.Objects) {if (Game.Objects[i].amount>0) highestBuilding=Game.Objects[i];}

        Game.Prompt('<h3>Set your dragon\'s '+(slot==1?'secondary ':'')+'aura</h3>'+
                    '<div class="line"></div>'+
                    '<div id="dragonAuraInfo" style="min-height:60px;"></div>'+
                    '<div style="text-align:center;">'+str+'</div>'+
                    '<div class="line"></div>'+
                    '<div style="text-align:center;margin-bottom:8px;">'+(highestBuilding==0?'Switching your aura is <b>free</b> because you own no buildings.':'The cost of switching your aura is <b>1 '+highestBuilding.name+'</b>.<br>This will affect your CpS!')+'</div>'
                    ,[['Confirm',(slot==0?'Game.dragonAura':'Game.dragonAura2')+'=Game.SelectingDragonAura;'+(highestBuilding==0 || currentAura==Game.SelectingDragonAura?'':'Game.ObjectsById['+highestBuilding.id+'].sacrifice(1);')+'Game.ToggleSpecialMenu(1);Game.ClosePrompt();'],'Cancel'],0,'widePrompt');
        Game.DescribeDragonAura(Game.SelectingDragonAura);
    }
    Game.SelectingDragonAura=-1;
    Game.SetDragonAura=function(aura,slot)
    {
        Game.SelectingDragonAura=aura;
        Game.SelectDragonAura(slot,1);
    }
    Game.DescribeDragonAura=function(aura)
    {
        l('dragonAuraInfo').innerHTML=
        '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[aura].name+'</h4>'+
        '<div class="line"></div>'+
        Game.dragonAuras[aura].desc+
        '</div>';
    }

    Game.UpgradeDragon=function()
    {
        if (Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost())
        {
            PlaySound('snd/shimmerClick.mp3');
            Game.dragonLevels[Game.dragonLevel].buy();
            Game.dragonLevel=(Game.dragonLevel+1)%Game.dragonLevels.length;

            if (Game.dragonLevel>=Game.dragonLevels.length-1) Game.Win('Here be dragon');
            Game.ToggleSpecialMenu(1);
            if (l('specialPic')){var rect=l('specialPic').getBoundingClientRect();Game.SparkleAt((rect.left+rect.right)/2,(rect.top+rect.bottom)/2);}
            Game.recalculateGains=1;
            Game.upgradesToRebuild=1;
        }
    }

    Game.ToggleSpecialMenu=function(on)
    {
        if (on)
        {
            var pic='';
            var frame=0;
            if (Game.specialTab=='santa') {pic='santa.png';frame=Game.santaLevel;}
            else if (Game.specialTab=='dragon') {pic='dragon.png';frame=Game.dragonLevels[Game.dragonLevel].pic;}
            else {pic='dragon.png';frame=4;}

            var str='<div id="specialPic" style="position:absolute;left:-16px;top:-64px;width:96px;height:96px;background:url(img/'+pic+');background-position:'+(-frame*96)+'px 0px;filter:drop-shadow(0px 3px 2px #000);-webkit-filter:drop-shadow(0px 3px 2px #000);"></div>';
            str+='<div class="close" onclick="PlaySound(\'snd/press.mp3\');Game.ToggleSpecialMenu(0);">x</div>';

            if (Game.specialTab=='santa')
            {
                var moni=Math.pow(Game.santaLevel+1,Game.santaLevel+1);

                str+='<h3>'+Game.santaLevels[Game.santaLevel]+'</h3>';
                if (Game.santaLevel<14)
                {
                    str+='<div class="line"></div>'+
                    '<div class="optionBox" style="margin-bottom:0px;"><a class="option framed large title" '+Game.clickStr+'="Game.UpgradeSanta();">'+
                        '<div style="display:table-cell;vertical-align:middle;">Evolve</div>'+
                        '<div style="display:table-cell;vertical-align:middle;padding:4px 12px;">|</div>'+
                        '<div style="display:table-cell;vertical-align:middle;font-size:65%;">cost :<div'+(Game.cookies>moni?'':' style="color:#777;"')+'>'+Beautify(Math.pow(Game.santaLevel+1,Game.santaLevel+1))+' '+(Game.santaLevel>0?'cookies':'cookie')+'</div></div>'+
                    '</a></div>';
                }
            }
            else if (Game.specialTab=='dragon')
            {
                var level=Game.dragonLevels[Game.dragonLevel];

                str+='<h3>'+level.name+'</h3>';

                if (Game.dragonLevel>=5)
                {
                    var icon=Game.dragonAuras[Game.dragonAura].pic;
                    str+='<div class="crate enabled" style="opacity:1;position:absolute;right:18px;top:-58px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SelectDragonAura(0);" '+Game.getTooltip(
                        '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[Game.dragonAura].name+'</h4>'+
                        '<div class="line"></div>'+
                        Game.dragonAuras[Game.dragonAura].desc+
                        '</div>'
                    ,'top')+
                    '></div>';
                }
                if (Game.dragonLevel>=21)
                {
                    var icon=Game.dragonAuras[Game.dragonAura2].pic;
                    str+='<div class="crate enabled" style="opacity:1;position:absolute;right:80px;top:-58px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;" '+Game.clickStr+'="PlaySound(\'snd/tick.mp3\');Game.SelectDragonAura(1);" '+Game.getTooltip(
                        '<div style="min-width:200px;text-align:center;"><h4>'+Game.dragonAuras[Game.dragonAura2].name+'</h4>'+
                        '<div class="line"></div>'+
                        Game.dragonAuras[Game.dragonAura2].desc+
                        '</div>'
                    ,'top')+
                    '></div>';
                }

                if (Game.dragonLevel<Game.dragonLevels.length-1)
                {
                    str+='<div class="line"></div>'+
                    '<div class="optionBox" style="margin-bottom:0px;"><a class="option framed large title" '+Game.clickStr+'="Game.UpgradeDragon();">'+
                        '<div style="display:table-cell;vertical-align:middle;">'+level.action+'</div>'+
                        '<div style="display:table-cell;vertical-align:middle;padding:4px 12px;">|</div>'+
                        '<div style="display:table-cell;vertical-align:middle;font-size:65%;">sacrifice<div'+(level.cost()?'':' style="color:#777;"')+'>'+level.costStr()+'</div></div>'+
                    '</a></div>';
                }
                else
                {
                    str+='<div class="line"></div>'+
                    '<div style="text-align:center;margin-bottom:4px;">'+level.action+'</div>';
                }
            }

            l('specialPopup').innerHTML=str;

            l('specialPopup').className='framed prompt onScreen';
        }
        else
        {
            if (Game.specialTab!='')
            {
                Game.specialTab='';
                l('specialPopup').className='framed prompt offScreen';
                setTimeout(function(){if (Game.specialTab=='') {/*l('specialPopup').style.display='none';*/l('specialPopup').innerHTML='';}},1000*0.2);
            }
        }
    }
    Game.DrawSpecial=function()
    {
        var len=Game.specialTabs.length;
        if (len==0) return;
        Game.LeftBackground.globalAlpha=1;
        var y=Game.LeftBackground.canvas.height-24-48*len;
        var tabI=0;

        for (var i in Game.specialTabs)
        {
            var selected=0;
            var hovered=0;
            if (Game.specialTab==Game.specialTabs[i]) selected=1;
            if (Game.specialTabHovered==Game.specialTabs[i]) hovered=1;
            var x=24;
            var s=1;
            var pic='';
            var frame=0;
            if (hovered) {s=1;x=24;}
            if (selected) {s=1;x=48;}

            if (Game.specialTabs[i]=='santa') {pic='santa.png';frame=Game.santaLevel;}
            else if (Game.specialTabs[i]=='dragon') {pic='dragon.png';frame=Game.dragonLevels[Game.dragonLevel].pic;}
            else {pic='dragon.png';frame=4;}

            if (hovered || selected)
            {
                var ss=s*64;
                var r=Math.floor((Game.T*0.5)%360);
                Game.LeftBackground.save();
                Game.LeftBackground.translate(x,y);
                if (Game.prefs.fancy) Game.LeftBackground.rotate((r/360)*Math.PI*2);
                Game.LeftBackground.globalAlpha=0.75;
                Game.LeftBackground.drawImage(Pic('shine.png'),-ss/2,-ss/2,ss,ss);
                Game.LeftBackground.restore();
            }

            if (Game.prefs.fancy) Game.LeftBackground.drawImage(Pic(pic),96*frame,0,96,96,(x+(selected?0:Math.sin(Game.T*0.2+tabI)*3)-24*s),(y-(selected?6:Math.abs(Math.cos(Game.T*0.2+tabI))*6)-24*s),48*s,48*s);
            else Game.LeftBackground.drawImage(Pic(pic),96*frame,0,96,96,(x-24*s),(y-24*s),48*s,48*s);

            tabI++;
            y+=48;
        }

    }

编辑9:
我找到了一种无需点击画布的方法。

URL GOTO=javascript:Game.UpgradeSanta()
URL GOTO=javascript:Game.UpgradeDragon()

如果有人知道如何单击此画布,请告诉我。 我现在有办法解决这个问题,但仍然没有解决方案

javascript html canvas firefox-addon
1个回答
0
投票

我知道这是非常非常非常古老的,但我最近来这里是为了弄清楚同样的事情,并且使用这个线程我已经能够找到另一种解决方法。

您可以使用

打开圣诞老人菜单
Game.specialTab=Game.specialTabs[0];Game.ToggleSpecialMenu(1);PlaySound('snd/press.mp3');

您可以使用

打开 Dragon 菜单
Game.specialTab=Game.specialTabs[1];Game.ToggleSpecialMenu(1);PlaySound('snd/press.mp3');

要关闭其中任何一个,您可以使用

Game.ToggleSpecialMenu(0);PlaySound('snd/press.mp3');

我一直使用 Selenium 将它们推送到浏览器控制台,它们在那里工作,如果你不想播放声音,你可能可以将其剪掉,但我还没有测试过。

© www.soinside.com 2019 - 2024. All rights reserved.