메뉴 건너뛰기

app

[Chrome] 플러그인 개발 - 특정 스트링 치환

suritam92013.04.25 02:40조회 수 2673댓글 0

  • 1
    • 글자 크기

text 등은 정규식을 이용해 충분히 가공이 가능하다.


content 처리 예제를 이용해 sandwich가 검색될 경우 input을 제거하는 실험을 수행하였다.



https://developer.chrome.com/extensions/samples.html 의 Page action by content 를 이용해 구현하였으며,


바뀐 내용은 간단하다.


contentscript.js 에


/*

 * Copyright (c) 2010 The Chromium Authors. All rights reserved.  Use of this

 * source code is governed by a BSD-style license that can be found in the

 * LICENSE file.

 */

var regex = /sandwich/;


// Test the text of the body element against our regular expression.

if (regex.test(document.body.innerText)) {

  // The regular expression produced a match, so notify the background page.

  document.body.innerHTML = document.body.innerHTML.replace(new RegExp("input", "g"), "");

  chrome.extension.sendRequest({}, function(response) {});

} else {

  // No match was found.

}


한 줄만 추가되었다.


  document.body.innerHTML = document.body.innerHTML.replace(new RegExp("input", "g"), "");


ss.PNG

suritam9 (비회원)
  • 1
    • 글자 크기
[iphone] 탈옥폰에 ipa, deb 설치하기 (by suritam9) [fortify] C/C++ 진단하기 (by suritam9)

댓글 달기

suritam9
2013.04.25 조회 6108
suritam9
2013.04.04 조회 2197
suritam9
2012.09.14 조회 2515
suritam9
2012.06.24 조회 2366
suritam9
2012.06.24 조회 2776
suritam9
2012.06.24 조회 2532
suritam9
2012.06.22 조회 2582
박영식
2011.09.22 조회 2544
박영식
2011.09.21 조회 2488
박영식
2011.02.18 조회 2964
박영식
2010.09.29 조회 4757
첨부 (1)
ss.PNG
45.3KB / Download 51
위로