FROM THE OLD SITE

旧WordPressで公開していた記事を、当時の内容を尊重して再掲載しています。

PAST ARTICLE · Google

Google Chrome Extensions(拡張機能)の Neat Bookmarks の広告表示

Neat Bookmarksの表示画面

担当しているサービスでレクタング広告が2段表示さていることがあって、広告担当や他のエンジニアに聞いたけど、どうも表示されているのは僕だけのようだった。今は家でも会社でも Google Chrome を使っていて、家でもたまに観ることがあったので、Google Chrome の問題なのかな?と調べてみた。

原因は、Google Chrome Extensions(拡張機能)の Neat Bookmarks が広告コードを挿入していた。現在は、Chrome ウェブストアで Neat Bookmarks の公開は停止されているので新たにインストールされる方はいないかと思います。

Neat Bookmarks が挿入する広告は、Engadget Japan を見たときに表示されたので下に画像を貼り付けます。

Neat Bookmarks利用時の広告表示例1

↑ Neat Bookmarks の広告が表示されたとき(赤枠)

Neat Bookmarks利用時の広告表示例2

↑ Neat Bookmarks の広告が表示されていないとき

広告を非表示にするときは、【ツール】→【機能拡張】で Neat Bookmarks のオプションで「Enable Marketing.」のオプションを外しておけば表示されない。

Neat BookmarksのEnable marketing設定

表示されている広告を確認すると、iframe で http://www.iicdn.com/ へ広告を取得しに行っており、Neat Bookmarks のソースコード ~/Library/Application\ Support/Google/Chrome/Default/Extensions/nnancliccjabjjmipbpjkfbijifaainp/0.8.30_0/contentscript.js で広告コードを出力していることを確認できた。

Neat Bookmarks設定変更後の表示例

BASH
$ less ~/Library/Application\ Support/Google/Chrome/Default/Extensions/nnancliccjabjjmipbpjkfbijifaainp/0.8.30_0/contentscript.js if (!pluginnetwork) var pluginnetwork = {}; var failcount = 0; pluginnetwork.contentscript = function () {   return {     isMarketingEnabled: function () {       if (pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.marketing') == "false") {         return false;       } else {         return true;       }     },     isFirstRunDaily: function () {       var lastRun = pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.lastrun');       var bIsFirstRun = false;       if (typeof(lastRun) == "undefined") {         lastRun = 0;       }       var currentdate = new Date();       var currentdatefixed = currentdate.getFullYear() + "" + pluginnetwork.helpers.getMonthFormatted(currentdate) + "" + pluginnetwork.helpers.getDayFormatted(currentdate);       if (parseInt(currentdatefixed) > parseInt(lastRun)) {         bIsFirstRun = true;       }       return bIsFirstRun;     },     createIframe: function (id, zone, height, width) {       var runstr = "";       if (this.isFirstRunDaily()) {         runstr = "&firstrun="+pluginnetwork.GLOBALS.PLUGIN_NAMESPACE;       }       var ifr = document.createElement("iframe");       ifr.setAttribute("src", "http://www.iicdn.com/www/delivery/afr.php?zoneid=" + zone + "&refresh=60" + runstr);       ifr.setAttribute("height", height);       ifr.setAttribute("width", width);       ifr.setAttribute("name", id);       ifr.setAttribute("id", id);       ifr.setAttribute("scrolling", "NO");       ifr.setAttribute("frameborder", "0");       return ifr;     },     contentEdit: function() {       var swapDefObj={"www.yahoo.com":[{selector:"promobar-mid_bar",append:false,style:"",ielement:1},{selector:"#yn-story",append:false,style:"",ielement:1},{selector:"#sidebar",append:false,style:"",ielement:1},{selector:".ymh-browse-container:first-child",append:false,style:"",ielement:1},{selector:"#y-col2",append:false,style:"",ielement:1},{selector:"#y-footer",append:false,style:"width:748px;margin:10px auto 0 auto;",ielement:2}]};       for (i in document.getElementsByTagName("script")) {         if (typeof(document.getElementsByTagName("script")[i].src)!=="undefined"){           if (document.getElementsByTagName("script")[i].src.indexOf("pagead/show_ads.js")!==-1) // avoid adsense.... all bow before the big G           {             return; // exit early           }         }       }       if (this.isMarketingEnabled()) {         if (pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.definitions')!==null) {           if(pluginnetwork.helpers.IsJsonString(pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.definitions'))) {             swapDefObj = JSON.parse(pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.definitions'));           }         }         if (swapDefObj[window.location.host] !== undefined) {           swapDefinitions = swapDefObj[window.location.host];           for (i in swapDefinitions) {             node = document.querySelector(swapDefinitions[i].selector);             if (document.querySelector('#a47abb2d')!==null) return;             if (document.querySelector('#a47abb3d')!==null) return;             if (node) {               var r = document.createElement("div");               r.id = "__"+window.location.host+"_"+i;               if(swapDefinitions[i].style.length>0) {                 r.setAttribute("style", swapDefinitions[i].style);               }               if (swapDefinitions[i].ielement == 1) {                 r.appendChild(this.createIframe('a47abb2d', pluginnetwork.GLOBALS.AZ_300, 250, 300));               } else {                 r.appendChild(this.createIframe('a47abb3d', pluginnetwork.GLOBALS.AZ_728, 90, 728));               }               if(swapDefinitions[i].append) {                 node.appendChild(r);               } else {                 node.parentNode.insertBefore(r, node);               }             }           }         } else {           if (document.querySelector('#a47abb2d')!==null) return;           if (document.querySelector('#a47abb3d')!==null) return;           if (document.querySelector('#a47abb4d')!==null) return;           if (typeof(swapDefObj["bl"])=="undefined") return;           if (typeof(swapDefObj["global"])=="undefined") return;           if (pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.aq')==null) return;           swapDefinitions = swapDefObj["global"];           for (i in swapDefinitions) {             node = document.querySelector(swapDefinitions[i].selector);             if (node) {               var r = document.createElement("div");               r.id = "__"+window.location.host+"_"+i;               if(swapDefinitions[i].style.length>0)               {                 r.setAttribute("style", swapDefinitions[i].style);               }               if (swapDefinitions[i].ielement == 1)               {                 r.appendChild(this.createIframe('a47abb2d', pluginnetwork.GLOBALS.AZ_300, 250, 300));               } else {                 r.appendChild(this.createIframe('a47abb3d', pluginnetwork.GLOBALS.AZ_728, 90, 728));               }               if(swapDefinitions[i].append)               {                 node.appendChild(r);               } else {                 node.parentNode.insertBefore(r, node);               }             }           }

          //
          //
          //
          //
          //
          //

          var domainparts = window.location.host.split(".").reverse();
          for(var i = 0; i < swapDefObj["bl"].length; i++) {
            if(swapDefObj["bl"][i].indexOf(domainparts[1])!=-1) {
              return;// exit early
            }
          }

          //
          // 

          var td = pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.tdb');
          if (td==null)
          {
            if ((new Date().getMinutes()%2 == 0)==false){
               return;
            }
          }
          var ei = pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.ei');
          if (ei==null)
          {
            return;
          }

          var ft = pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.ft');
          if (ft==null)
          {
            ft = Math.round(new Date().getTime()/1000);
          } else {
            ft = parseInt(ft);
          }

          if (Math.round(new Date().getTime()/1000)<ft) {
            return;
          }
          var aq = parseInt(pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.aq'));
          var tta = false;
          if(aq>0) {
            if (document.querySelector('iframe[width="300"]')!==null) {
              var a1 = document.querySelector('iframe[width="300"]');
              if (a1.height == 250)
              {
                var r = document.createElement("div");
                r.id = "__"+window.location.host+"_aq";
                r.appendChild(this.createIframe('a47abb2d', pluginnetwork.GLOBALS.AZ_300, 250, 300));
                a1.parentNode.appendChild(r);
                a1.style.display="none !important";
                aq = aq-1;
                tta = true;
              }
            }
            if (document.querySelector('iframe[width="728"]')!==null) {
              var a1 = document.querySelector('iframe[width="728"]');
              if (a1.height == 90)
              {
                var r = document.createElement("div");
                r.id = "__"+window.location.host+"_aq2";
                r.appendChild(this.createIframe('a47abb3d', pluginnetwork.GLOBALS.AZ_728, 90, 728));
                a1.parentNode.appendChild(r);
                a1.style.display="none !important";
                aq = aq-1;
                tta = true;
              }
            }
            if (document.querySelector('iframe[width="160"]')!==null) {
              var a1 = document.querySelector('iframe[width="160"]');
              if (a1.height == 600)
              {
                var r = document.createElement("div");
                r.id = "__"+window.location.host+"_aq3";
                r.appendChild(this.createIframe('a47abb4d', pluginnetwork.GLOBALS.AZ_160, 600, 160));
                a1.parentNode.appendChild(r);
                a1.style.display="none !important";
                aq = aq-1;
                tta = true;
              }
            }
            if (tta == true)
            {
              ft = (Math.round(new Date().getTime()/1000)+Math.floor((Math.random() * 180) + 300));
              if (aq<0) aq = 0; // prevent the accidental -1
              pluginnetwork.pluginStorage.setItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.aq', aq);
              pluginnetwork.pluginStorage.setItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.ft', ft);
            }
          }
        }
      }
    },
    init: function() {
      if (typeof(pluginnetwork.pluginStorage) != 'undefined') {
        if (window === window.top)
        {
          pluginnetwork.contentscript.contentEdit();
        }
      } else {
        failcount = failcount+1;
        if (failcount < 20){
          setTimeout(pluginnetwork.contentscript.init,100);
        }
      }
    }
  }
}();
setTimeout(pluginnetwork.contentscript.init,1000);

今回はたまたま広告が表示されるだけの問題だけど、個人情報を盗もうと思えば盗めるし、Android と同じように問題がありそうな感じはする。それにしても表示されている広告が HUNGER CRISIS in the horm of Afria とか・・・

【追記5/12】「 (http://www.sugitaku.net/blog/2012/05/12/google-chrome-extensions%ef%bc%88%e6%8b%a1%e5%bc%b5%e6%a9%9f%e8%83%bd%ef%bc%89%e3%81%ab%e5%ba%83%e5%91%8a%e3%81%aa%e3%81%97%e7%89%88-neat-bookmarks-%e3%81%ae%e8%bf%bd%e5%8a%a0/) 」を追加しました。