1

목표는 Google의 Google Translator Toolkit에 키보드 단축키를 추가하는 것입니다. 대부분의 기능에는 키보드 단축키가 있지만이 두 가지 기능은 없습니다.Google 서비스 iframe에서 버튼 클릭 시뮬레이션을위한 북마크 북

첫 번째 기능을 병합이라고합니다. 이 북마크릿을 실행하면 올바르게 실행됩니다.

모두에 적용 기능이 더 복잡합니다. 무엇으로 대체 할 무엇을 : 볼 반복 횟수 대화 상자를 만들고 매개 변수를 설정하는 버튼을 클릭

# 1 : 일반적으로이 기능을 실행하기 위해 세 번 클릭해야합니다.
# 2 클릭 '모두 적용'하고 대화 요소를 숨길
# 3을 통해 실제 교체를 트리거합니다.

Google의 내부 코드가 엉망이되고 싶지 않으므로 마우스를 클릭했을 때와 같은 일반적인 클릭이 가장 좋을 것입니다. 충분히 쉽게

# 2, # 3 화재 : 같은 북마크, 일시 정지로 : 나는 두 개의 버튼으로 팝업하도록되어 반복 횟수 버튼에 클릭을 시뮬레이션 할 수

javascript:(function(pause) { 
document.evaluate("//div[(@id='fnrDialogParent')]/div[(@class='modal-dialog gtc-rep-modal-dialog')]/div[(@class='modal-dialog-buttons')]/button[(text()='Apply to all')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click(); 
setTimeout(() => document.evaluate("//div[(@id='fnrDialogParent')]/div[(@class='modal-dialog gtc-rep-modal-dialog')]/div[(@class='modal-dialog-buttons')]/button[(text()='Exit')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click(), pause) 
      })(400); 

I 작업을 마치려면 클릭해야합니다. 버튼 자체는 iframe 안에 img가있는 div입니다. 나는 방법의 대부분은 내가 클릭 시뮬레이션, 최신이 this one 인 여기를 발견했는데, 그것은 (참조가 제대로 촬영)

var ifrm = document.querySelectorAll('iframe')[2];<br> 
$(ifrm).contents().find('img.jfk-button-img.gtc-img-rep').click(); 

는 (버튼 자체가 가진 DIV 모두 같은 작동하지 않습니다 ..이 내 질문에 대한 대답 북마크가

<div role="button" class="goog-inline-block jfk-button jfk-button-standard jfk-button-narrow jfk-button-collapse-left jfk-button-collapse-right jfk-button-clear-outline" tabindex="0" id="goog-gtc-repbutton" aria-label="Repeated: 3" data-tooltip="Repeated: 3" style="user-select: none;"><img src="./images/cleardot.gif" class="jfk-button-img gtc-img-rep" style="width: 21px; height: 21px;"></div> 

답변

0
javascript: (function() { 
    const a = f => new MouseEvent(f, { bubbles: !0 }), 
     b = f =>() => document.querySelector(f).click(), 
     c = f => `#fnrDialogParent .gtc-rep-modal-dialog .modal-dialog-buttons button[name=${f}]`, 
     d = { imgSel: (f =>() => { 
       const g = a('mousedown'), 
        h = a('mouseup'), 
        i = document.querySelector(f); 
       i.dispatchEvent(g), i.dispatchEvent(h) })('img.jfk-button-img.gtc-img-rep'), applyToAll: b(c('repDialogReplaceAll')), exit: b(c('repDialogExit')) }; 
    d.imgSel(), d.applyToAll(), d.exit() })(); 

: IMG 내부 세그먼트가 다른 곳에 여부를 반복 버튼 사용이 가능한 또는 -disabled 중 하나인지에 따라 여기에 활성화 된 버튼에 대한 HTML 코드는 3 번 클릭합니다. This answer tipped me off.

+0

질문이나 답변에서 문제가 무엇이며 어떻게 수정했는지 완전히 명확하지 않습니다. –