2017-11-17 7 views
0

my previous problem(많은 도움이 필요함)으로 해결했습니다. 그러나 나는 새로운 코드를 실행 한 직후 :콘솔에서 javascript 코드를 북마크로 실행하면 다른 결과가 나타납니다.

책갈피로 대신 콘솔 에서

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

(자바 스크립트없이 : 물론), 그것은 다른 결과를 주었다. 콘솔은 한 줄에 한 번에 한 줄씩 테스트했을 때 예상대로 실행했습니다. 그러나 책갈피는 페이지의 모든 내용을 버튼으로 대체했습니다!

+0

왜 그냥'tt.innerHTML = RAW'을하지? – Barmar

+0

원래 코드를 만들 때 나는 피곤했다. 나는 가장 새로운 것을 붙여 넣는 것을 잊어 버렸다. 그들은 동일하게 작동합니다. – LCB

+0

이것은 매우 이상합니다. DevTools의 Elements 패널에서 페이지의 나머지 부분을 볼 수 있지만 브라우저 탭에는 나타나지 않습니다. 그리고 관리자의 요소 위로 마우스를 가져 가면 브라우저 탭에 아무 것도 강조 표시되지 않습니다. – Barmar

답변

0

북마크릿 끝에 false을 추가하십시오. 분명히 브라우저는 북마클릿을 탐색으로 처리하므로 반환하면 새 페이지 만 표시됩니다. 그러나 인라인 자바 스크립트가 false을 반환하면 링크를 클릭하는 기본 동작을 사용할 수 없습니다.

<a href="javascript:var tt=document.createElement('div'); 
 
tt.setAttribute('id', 'CMenu'); 
 
var g=document.getElementById('adCost'); 
 
var RAW='<button id =&quot;save1Button&quot; onclick=&quot;save1()&quot;>SAVE SLOT 1</button>' + 
 
'<button id =&quot;load1Button&quot; onclick=&quot;load1()&quot;>LOAD SLOT 1</button>' + 
 
'<button id =&quot;save2Button&quot; onclick=&quot;save2()&quot;>SAVE SLOT 2</button>' + 
 
'<button id =&quot;load2Button&quot; onclick=&quot;load2()&quot;>LOAD SLOT 2</button>' + 
 
'<button id =&quot;resetButton&quot; onclick=&quot;reset()&quot;>RESET ALL PROGRESS</button>' + 
 
'<button id =&quot;freeClipsButton&quot; onclick=&quot;cheatClips()&quot;>Free Clips</button>' + 
 
'<button id =&quot;freeMoneyButton&quot; onclick=&quot;cheatMoney()&quot;>Free Money</button>' + 
 
'<button id =&quot;freeTrustButton&quot; onclick=&quot;cheatTrust()&quot;>Free Trust</button>' + 
 
'<button id =&quot;freeOpsButton&quot; onclick=&quot;cheatOps()&quot;>Free Ops</button>' + 
 
'<button id =&quot;freeCreatButton&quot; onclick=&quot;cheatCreat()&quot;>Free Creativity</button>' + 
 
'<button id =&quot;freeYomiButton&quot; onclick=&quot;cheatYomi()&quot;>Free Yomi</button>' + 
 
'<button id =&quot;resetPrestige&quot; onclick=&quot;resetPrestige()&quot;>Reset Prestige</button>' + 
 
'<button id =&quot;destroyAllHumansButton&quot; onclick=&quot;cheatHypno()&quot;>Destroy all Humans</button>' + 
 
'<button id =&quot;freePrestigeU&quot; onclick=&quot;cheatPrestigeU()&quot;>Free Prestige U</button>' + 
 
'<button id =&quot;freePrestigeS&quot; onclick=&quot;cheatPrestigeS()&quot;>Free Prestige S</button>' + 
 
'<button id =&quot;debugBattleNumbers&quot; onclick=&quot;setB()&quot;>Set Battle Number 1 to 7</button>' + 
 
'<button id =&quot;availMatterZero&quot; onclick=&quot;zeroMatter()&quot;>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>

+0

해결되었습니다! 정말 고맙습니다! – LCB

관련 문제