Chrome 기록을 AWS로부터 보호 (chrome-extension)

배경



오늘 조사한 그게 어디였는지~

역사에 남아있는 하즈군요,,,,



, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

aws 콘솔 뿐!



이력을 전혀 남기지 않을 수도 있고, 필요없는 이력은 지우고 싶고,
맞아! 교토에 가자 chrome-extension을 만들자

사양


  • 지정된 URL 만 기록에서 지우기
  • 와일드 카드 지정 가능

  • 브레스트



    특히 없음. 설정 화면이 귀찮아 보인다 ← 실제로 그랬다

    파일 구성



    마지막 반성을 활용하고 분화하지 않음

    root_folder
    │ manifest.json
    │ options.html

    ├─img
    │ icon-128x128.png
    │ icon-16x16.png
    │ icon-48x48.png

    ├─js
    │ background.js
    │ jquery-3.4.1.min.js
    │ script.js

    └─css
    chromeapp.js

    출처


  • manifest.json

  • 기록을 삭제할 수 있는 권한이 history
    설정을 로컬 스토리지에 저장할 수 있는 권한이 storage
    다국어 대응은 귀찮아

    manifest.json
    {
      "name": "off-the-record History",
      "version": "1.0.0",
      "manifest_version": 2,
      "description": "off-the-record history",
      "permissions": [
        "history",
        "storage"
      ],  
      "background": {
        "scripts": ["js/background.js"]
      },
      "icons": {
        "128": "img/icon-128x128.png",
        "48": "img/icon-48x48.png",
        "16": "img/icon-16x16.png"
      },
      "options_ui": {
        "page": "options.html",
        "chrome_style": false
      }
    }
    
  • script.js

  • 설정 화면의 js이므로 생략
    jquery-3.4.1.min.js도 설정 화면 용
  • background.js

  • 설정과 match 하면, chrome.history.deleteUrl 하면 됩니다.
    이벤트는 console.log에서 확인하고 onVisited에만 적용했습니다.
    match하자마자 처리를 끝내고 싶기 때문에 for (var i=0;・・・를 사용했다. forEach는 break 할 수 없다고 한다.

    background.js
    chrome.history.onVisited.addListener(function(history_item) {
    
        chrome.storage.sync.get([chrome.runtime.id], function(val){
    
          var jsonstr = val[chrome.runtime.id];
          if (!jsonstr) {
            return;
          } 
          var patterns = JSON.parse(jsonstr);
          if (0 == patterns.length) {
            return;
          } 
    
          for (var i=0; i<patterns.length; i++) {
            var pattern = patterns[i];
            if (!pattern.checked) {
              continue;
            }
    
            if (history_item.url.match(pattern.regexp)) {
              chrome.history.deleteUrl({url: history_item.url});
              break;
            }
          }
        });
    
    });
    
    

    주의점



    마지막주의 사항과 동일

    공개



    off-the-record History

    스스로 말하는 것도 있습니다만, 편리합니다.
    현재 다음 4가지를 지정하고 있습니다.

    기록 제외 설정


    https://*.slack.com/
    https://*.aws.amazon.com/
    https://*.heroku.com/
    https://photos.google.com/
    

    도전


  • 설정을 가져오고 내보낼 수 있으면 유용합니다

  • 귀찮아서 만년 과제. 사용자 수가 1000을 넘으면 생각한다는 것으로

    우려사항


  • 설정 URL이 늘어날 때의 성능. 느린 것 같으면 상한수를 설정한다
  • 좋은 웹페이지 즐겨찾기