728x90 자바스크립트24 자바스크립트 - XPATH 문법으로 DOM ELEMENT 가져오기 XPATH 문법으로 단일 요소 가져오기 function getElementByXpath(path){ return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } console.log( getElementByXpath("//html[1]/body[1]/div[1]")); XPATH 문법으로 다중 요소 가져오기 function getElementsByXPath(xpath, parent) { let results = []; let query = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE.. 2023. 11. 12. 자바스크립트 - GET 파라미터 추출하기 let url = new URL("https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&q=mdn%20query%20string") let params = new URLSearchParams(url.search); let sourceid = params.get('sourceid') // 'chrome-instant' let q = params.get('q') // 'mdn query string' let ie = params.has('ie') // true params.append('ping','pong') console.log(sourceid) console.log(q) console.log(ie) console.log(p.. 2023. 10. 26. 자바스크립트 - 자바스크립트 난독화 사이트(obfuscator.io) 사이트 주소 https://obfuscator.io/ JavaScript Obfuscator Tool JavaScript Obfuscator Tool A free and efficient obfuscator for JavaScript (including support of ES2022). Make your code harder to copy and prevent people from stealing your work. This tool is a Web UI to the excellent (and open source) javascript-obfuscato obfuscator.io // Paste your JavaScript code here function hi() { console.log("Hello .. 2023. 9. 5. 안드로이드 스튜디오 - 웹뷰(WebView) 자바스크립트 조작 private Boolean isLoadingFinished = false; ... WebView webView = findViewById(R.id.webView); webView.setWebViewClient(new WebViewClient(){ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); Toast.makeText(getApplicationContext(), "페이지 로드 중...", Toast.LENGTH_LONG).show(); isLoadingFinished = false; } @Override public void onPag.. 2023. 8. 23. 자바스크립트 - XPath 다루기, 반응속도 테스트 사이트 핵 만들기 XPath 선택자인 $x를 사용하는 방법도 있지만, setInterval 함수 내에 $x 선택자를 사용하려고 하면 VM3146:2 Uncaught ReferenceError: $x is not defined at :2:12 이라는 오류 메시지가 나온다. 그래서 evaluate 메서드를 이용해 XPath 표현식으로 특정 요소를 찾는 방법을 대신할 수 있다. evaluate 함수 구문 evaluate(xpathExpression, contextNode, namespaceResolver, resultType, result) 매개 변수 xpathExpression - XPath 표현식이 온다. contextNode - document 같은 context 노드가 입력된다. resultType - 결과 유형에 맞는.. 2023. 6. 23. 자바스크립트 - http를 https로 리다이렉트 if (window.location.protocol != "https:") { window.location.href = "https:" + window.location.href.substring(window.location.protocol.length); } if (document.location.protocol == 'http:') { document.location.href = document.location.href.replace('http:', 'https:'); } 출처: https://greendreamtrre.tistory.com/672 Javascript (자바스크립트) HTTP 접속 시 HTTPS로 리다이렉트 보통은 톰캣 서버 설정 등에서 자동으로 리다이렉트 시키도록 하지만 각 페이지마다.. 2023. 5. 18. 셀레니움 - xpath, 텍스트가 포함된 요소 선택(contains text) 원하는 문자열인 요소 찾기 ex) 요소의 내용이 foo인 것을 찾기 //myparent/mychild[text() = 'foo'] 원하는 문자열이 포함한(contains) 요소 찾기 ex) ABC라는 내용을 포함한 있는 요소 찾기 //*[contains(text(),'ABC')] 파이썬 사용 예시 driver.find_element_by_xpath('//span[contains(text(),"ABC")]') 자바스크립트(브라우저 개발자 도구) 사용 예시 $x("//*[contains(text(),'12:00')]") 그 문자인 것을 찾기 $x('//*[text()="네이버로 이용하기"]') 속성(class나 id) 값이 특정 문자로 시작하는 요소 찾기 $x("//div[starts-with(@class,.. 2023. 5. 7. 자바스크립트 - 현재 script 태그 삭제하기 2023. 4. 4. 자바스크립트 - SMS 문자 보내기 SMS보내기 location.href = sms:수신자번호?body=보낼메세지; 출처: https://ttowa.tistory.com/m/entry/JS-%EC%9B%B9Mobile%EC%97%90%EC%84%9C-SMS-%EB%AC%B8%EC%9E%90%EB%B3%B4%EB%82%B4%EA%B8%B0 [JS] 웹(Mobile)에서 SMS 문자보내기 1.Android(안드로이드) SMS보내기 location.href = sms:수신자번호?body=보낼메세지; 2.IOS(아이폰) SMS보내기 location.href = sms:수신자번호&body=보낼메세지; 3.Android & IOS 자동 분기 실제 디바이스에서 테스트 해 ttowa.tistory.com 2023. 3. 2. 자바스크립트 - 브라우저 탭이 활성화인지 확인하기(document.hidden) if (document.hidden) console.log('비활성화'); else console.log('활성화'); 출처: https://stackoverflow.com/questions/1760250/how-to-tell-if-browser-tab-is-active How to tell if browser/tab is active Possible Duplicate: Is there a way to detect if a browser window is not currently active? I have a function that is called every second that I only want to run if the current page is in the stackoverflow.com 2023. 2. 5. npm - 구글 번역기 모듈(translate-google) npm https://www.npmjs.com/package/translate-google translate-google A free and unlimited for Google Translate, Multi-translation support object input. Latest version: 1.5.0, last published: a year ago. Start using translate-google in your project by running `npm i translate-google`. There are 13 other projects in the npm r www.npmjs.com 설치 npm i translate-google 예제 const translate = require('tra.. 2022. 11. 7. 자바스크립트 - text to speech(text2speech)(SpeechSynthesisUtterance) function say(m) { var msg = new SpeechSynthesisUtterance(); var voices = window.speechSynthesis.getVoices(); msg.voice = voices[10]; msg.voiceURI = "native"; msg.volume = 1; msg.rate = 1; msg.pitch = 0.8; msg.text = m; msg.lang = 'en-US'; speechSynthesis.speak(msg); } 출처: https://stackoverflow.com/questions/15653145/using-google-text-to-speech-in-javascript Using Google Text-To-Speech in Javascr.. 2022. 11. 5. 이전 1 2 다음 728x90