I was very happy to see that I was able to solve my previous problem (with some much needed help). But soon after I had ran the new code:
javascript:var tt=document.createElement('div');
tt.setAttribute('id', 'CMenu');
var g=document.getElementById('adCost');
var RAW='<button id ="save1Button" onclick=\"save1()\">SAVE SLOT 1</button>' +
'<button id ="load1Button" onclick="load1()">LOAD SLOT 1</button>' +
'<button id ="save2Button" onclick="save2()">SAVE SLOT 2</button>' +
'<button id ="load2Button" onclick="load2()">LOAD SLOT 2</button>' +
'<button id ="resetButton" onclick="reset()">RESET ALL PROGRESS</button>' +
'<button id ="freeClipsButton" onclick="cheatClips()">Free Clips</button>' +
'<button id ="freeMoneyButton" onclick="cheatMoney()">Free Money</button>' +
'<button id ="freeTrustButton" onclick="cheatTrust()">Free Trust</button>' +
'<button id ="freeOpsButton" onclick="cheatOps()">Free Ops</button>' +
'<button id ="freeCreatButton" onclick="cheatCreat()">Free Creativity</button>' +
'<button id ="freeYomiButton" onclick="cheatYomi()">Free Yomi</button>' +
'<button id ="resetPrestige" onclick="resetPrestige()">Reset Prestige</button>' +
'<button id ="destroyAllHumansButton" onclick="cheatHypno()">Destroy all Humans</button>' +
'<button id ="freePrestigeU" onclick="cheatPrestigeU()">Free Prestige U</button>' +
'<button id ="freePrestigeS" onclick="cheatPrestigeS()">Free Prestige S</button>' +
'<button id ="debugBattleNumbers" onclick="setB()">Set Battle Number 1 to 7</button>' +
'<button id ="availMatterZero" onclick="zeroMatter()">Set Avail Matter to 0</button>';
g.appendChild(tt);
document.getElementById('CMenu').innerHTML= RAW
as a bookmark instead of in the console (without javascript: of course), it gave different results. The console ran it as expected when tested line-by-line, and all at once. The bookmark however replaced all the content on the page with buttons!
Add false
to the end of the bookmarklet. Apparently the browser treats clicking on the bookmarklet as a navigation, so when it returns it only shows the new page. But if an inline Javascript returns false
, that disables the default action of clicking on the link.
<a href="javascript:var tt=document.createElement('div');
tt.setAttribute('id', 'CMenu');
var g=document.getElementById('adCost');
var RAW='<button id ="save1Button" onclick="save1()">SAVE SLOT 1</button>' +
'<button id ="load1Button" onclick="load1()">LOAD SLOT 1</button>' +
'<button id ="save2Button" onclick="save2()">SAVE SLOT 2</button>' +
'<button id ="load2Button" onclick="load2()">LOAD SLOT 2</button>' +
'<button id ="resetButton" onclick="reset()">RESET ALL PROGRESS</button>' +
'<button id ="freeClipsButton" onclick="cheatClips()">Free Clips</button>' +
'<button id ="freeMoneyButton" onclick="cheatMoney()">Free Money</button>' +
'<button id ="freeTrustButton" onclick="cheatTrust()">Free Trust</button>' +
'<button id ="freeOpsButton" onclick="cheatOps()">Free Ops</button>' +
'<button id ="freeCreatButton" onclick="cheatCreat()">Free Creativity</button>' +
'<button id ="freeYomiButton" onclick="cheatYomi()">Free Yomi</button>' +
'<button id ="resetPrestige" onclick="resetPrestige()">Reset Prestige</button>' +
'<button id ="destroyAllHumansButton" onclick="cheatHypno()">Destroy all Humans</button>' +
'<button id ="freePrestigeU" onclick="cheatPrestigeU()">Free Prestige U</button>' +
'<button id ="freePrestigeS" onclick="cheatPrestigeS()">Free Prestige S</button>' +
'<button id ="debugBattleNumbers" onclick="setB()">Set Battle Number 1 to 7</button>' +
'<button id ="availMatterZero" onclick="zeroMatter()">Set Avail Matter to 0</button>';
g.appendChild(tt);
document.getElementById('CMenu').innerHTML= RAW;
false;">Click</a>
<div>This is some text at the beginning.</div>
<div id="adCost"></div>
<div>This is text at the end</div>