--- /dev/null
+var port = chrome.runtime.connect({name: "contentscript"});
+port.postMessage({contentscript: "Hello background!"});
+port.onMessage.addListener(function(msg) {
+ if (msg.background == "Hello contentscript!") {
+ console.log('from background : ' + msg.background);
+ }
+});
+
+var app_id = location.href.split('/');
+
+if (app_id[app_id.length - 2] == 'installer' || app_id[app_id.length - 2] == 'extensions_settings') {
+ console.log('Except for installer and settings.');
+} else {
+ var cnt = 5;
+ var flag = 0;
+
+ var adv_div = document.createElement('div');
+
+ var video = document.createElement('video');
+ video.src = '../../extensions_repo/ad_plus/adv2.mp4';
+ video.type = 'video/mp4';
+ video.autoplay = 'true';
+
+ console.log('screen.availHeight : ', screen.availHeight);
+ console.log('screen.availWidth : ', screen.availWidth);
+
+ var video_style = document.createAttribute("style");
+ video_style.nodeValue = 'position: absolute; top:0px; left:0px; width:'+screen.availWidth+'px; height:'+screen.availHeight+'px; z-index:1; color:white; font-size:30px; font-weight:bold';
+ video.setAttributeNode(video_style);
+
+ adv_div.appendChild(video);
+
+ var text_div = document.createElement('div');
+ text_div.id = 'text';
+ var text_style = document.createAttribute('style');
+ text_style.nodeValue = 'position: absolute; top:'+(screen.availHeight - 100)+'px; left:'+(screen.availWidth - 250)+'px; width:200px; height:50px; z-index:3; color:white; font-size:20px; font-weight:bold';
+ text_div.setAttributeNode(text_style);
+ var text = document.createTextNode(cnt + ' 초 후에 SKIP 가능');
+ text_div.appendChild(text);
+
+ var skip_div = document.createElement('div');
+ var skip_style = document.createAttribute("style");
+ skip_style.nodeValue = 'background-color:rgba(0, 0, 0, .3); text-align: center; position: absolute; top:'+(screen.availHeight - 100)+'px; left:'+(screen.availWidth - 250)+'px; width:100px; height:33px; z-index:5; color:white; font-size:30px; font-weight:bold';
+ skip_div.setAttributeNode(skip_style);
+ skip_div.innerHTML = 'SKIP';
+
+ var text_div1 = document.createElement('div');
+ text_div1.id = 'text1';
+ var text_style = document.createAttribute('style');
+ text_style.nodeValue = 'position: absolute; top:10px; left:10px; width:300px; height:50px; z-index:3; color:white; font-size:20px; font-weight:bold';
+ text_div1.setAttributeNode(text_style);
+ var text1 = document.createTextNode('광고 영상이 재생 중입니다.');
+ text_div1.appendChild(text1);
+
+ skip_div.onclick = function() {
+ console.log('clicked skip ');
+ document.getElementsByTagName('body')[0].removeChild(skip_div);
+ document.getElementsByTagName('body')[0].removeChild(adv_div);
+ document.getElementsByTagName('body')[0].removeChild(text_div1);
+ clearInterval(timer);
+ };
+
+ document.getElementsByTagName('body')[0].appendChild(adv_div);
+ document.getElementsByTagName('body')[0].appendChild(text_div);
+ document.getElementsByTagName('body')[0].appendChild(text_div1);
+
+ var timer = setInterval(function() {
+ cnt--;
+
+ console.log('ended :' + video.ended);
+
+ if(video.ended == true) {
+ document.getElementsByTagName('body')[0].removeChild(adv_div);
+ document.getElementsByTagName('body')[0].removeChild(skip_div);
+ document.getElementsByTagName('body')[0].removeChild(text_div1);
+ clearInterval(timer);
+ }
+
+ if(cnt < 1 && flag == 0) {
+ flag = 1;
+ document.getElementsByTagName('body')[0].removeChild(text_div);
+ document.getElementsByTagName('body')[0].appendChild(skip_div);
+ //document.getElementById('skip').focus();
+ }
+ else if(flag == 0) {
+ document.getElementById('text').innerHTML = cnt + ' 초 후에 SKIP 가능';
+ }
+ }, 1000);
+
+ const DATA_HTML = '<div id="modal_div" style="display: block; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.7);"> \
+ <div id="content_div" style="background-color:rgb(255, 255, 255); position:absolute; width: 800px; height: 800px;"> \
+ <div id="img_header" style="height: 90px; text-align: center;"> \
+ <img src="../../extensions_repo/ad_plus/header.png" style="width: 788px; height: 80px;"> \
+ </div> \
+ <div id="img_body" style="height: 590px; text-align: center;" > \
+ <img src="../../extensions_repo/ad_plus/body.png" style="width: 788px; height: 590px;"> \
+ </div> \
+ <div id="img_footer" style="height: 90px;font-size: 50px; line-height:90px; vertical-align: middle; text-align: center;"> \
+ Link to site : \
+ <a href="http://www.samsung.com/sec/">samsung</a> \
+ </div> \
+ </div> \
+ </div>';
+
+ var setting = 112;
+
+ window.onkeydown = function() {
+ console.log('keycode : ', event.keyCode);
+
+ var key = event.keyCode;
+
+ if (key == setting) {
+ if (document.getElementById('modal_div')) {
+ var popup = document.getElementById('modal_div')
+ document.getElementsByTagName('body')[0].removeChild(popup);
+ }
+ else {
+ console.log('in setting');
+ document.body.insertAdjacentHTML('beforeend', DATA_HTML);
+
+ var top_val = (screen.availHeight / 2) - 400;
+ var left_val = (screen.availWidth / 2) - 400;
+
+ var modal = document.getElementById('modal_div');
+ document.getElementById('content_div').style.top = top_val+'px';
+ document.getElementById('content_div').style.left = left_val+'px';
+
+ modal.style.display = 'block';
+ }
+ }
+ }
+};
\ No newline at end of file