(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";function processVideoData(n){injectVideo(n)}function DownloadTemplate(n){var e=document.createElement("div"),t=n.files;e.style.cssText="position: relative;float: right;",e.innerHTML='<style>.wow-video-downloader-holder{ margin:0;width:140px;padding:0 5px;}\n    .wow-video-downloader-list-holder{margin:40px 0 0 -20px;padding: 0;position:absolute}\n    </style>\n    <div class="wow-video-downloader-holder">\n      <button class="download-btn">\n        <span>'+i18n("downloadBtn")+'</span>\n        <span class="icon-close icon"></span>\n      </button>\n    </div>\n    <div data-list class="wow-video-downloader-list-holder">\n      <div class="arrow"></div>\n      <div class="wow-video-downloader-list">'+$each(t,function(n,e){return'\n       <p class="download-item" data-seq="'+e+'">'+getFileDisplayName(n)+"</p>\n       "})+"\n      </div>\n    </div>\n    ";var o=(0,_dom.$)("[data-list]",e),i=(0,_dom.$)(".download-btn",e);return i.onclick=function(n){n.target.classList.contains("icon-close")?((0,_dom.removeNodeFromParent)(i),(0,_dom.removeNodeFromParent)(o)):toggleClass("open",o)},o.onclick=function(e){var o,i=e.target;(o=i.getAttribute("data-seq"))&&download((getInjector().beforeDownload||defaultDownloadHandler)(t[o],n))},e}function defaultDownloadHandler(n,e){var t=e.title,o=n.format,i=n.downloadPlugin,a=n.quality;return o&&(t=t+(a?"("+a+")":"")+"."+o),{title:t,link:n.link,downloadPlugin:i,quality:a}}function download(n){n.link&&n.title&&(n.href=location.href,(0,_message.sendMessageAsync)(_videoDownload.MSG_EVENT_VIDEO_DOWNLOAD_CHROME_DOWNLOAD,{filename:n.title,href:n.href,url:n.link,quality:n.quality,downloadPlugin:n.downloadPlugin},{noReply:1}))}function waitTarget(n,e,t){function o(){var i=(0,_dom.$)(n);return i?void e(i):setTimeout(o,t)}return t=t||500,o()}function getFileDisplayName(n){var e=n.format;return(n.quality||"")+(e?"("+e+")":"")}function i18n(n){return chrome.i18n.getMessage(n)}function $each(n,e,t){return n.map(e,t).join("")}function toggleClass(n,e){e.classList.contains(n)?e.classList.remove(n):e.classList.add(n)}function injectVideo(n){var e=DownloadTemplate(n),t=getInjector();t.inject(e)}function getInjector(){for(var n=location.hostname,e=0,t=Object.getOwnPropertyNames(injectHandlers).length;t>e;e++)if(injectHandlers[e].host.indexOf(n)>-1)return injectHandlers[e]}var _message=require(5),_dom=require(3),_videoDownload=require(4),injectHandlers=[{host:"www.facebook.com",inject:function(n){return waitTarget("#fbPhotoPageHeader .clearfix .lfloat",function(e){return e.appendChild(n)})}},{host:"www.xvideos.com",inject:function(n){return waitTarget("#main h2",function(e){return e.appendChild(n)})}},{host:"www.pornhub.com",inject:function(n){return waitTarget("h1.title",function(e){return e.appendChild(n)})}},{host:"www.redtube.com",inject:function(n){return waitTarget(".videoTitle",function(e){return e.appendChild(n)&&(e.style.overflow="visible")})}},{host:"www.tube8.com",inject:function(n){return waitTarget(".main-title",function(e){return e.appendChild(n)})}},{host:"www.dailymotion.com",inject:function(n){return waitTarget("#video_title",function(e){return e.appendChild(n)})}},{host:"www.vimeo.com",inject:function(n){return waitTarget(".title header",function(e){return e.appendChild(n)})}},{host:"www.gaytube.comn",inject:function(n){return waitTarget(".video-title",function(e){return((0,_dom.$)("div",e)||e).appendChild(n)})}},{host:"www.youporn.com",inject:function(n){return waitTarget(".heading2",function(e){return e.appendChild(n)})}},{host:"www.thumbzilla.com",inject:function(n){return waitTarget(".videoInfoBottom",function(e){e.style.overflow="visible";var t=(0,_dom.$)(".actionWrapper",e);t?e.insertBefore(n,t):e.appendChild(n)})}},{host:"www.pornhd.com",inject:function(n){n.style["float"]="none",n.style.display="inline-block",waitTarget(".section-title",function(e){e.appendChild(n);var t=(0,_dom.$)(".section-header")||e;t&&(t.style.overflow="visible")})}}];(0,_message.sendMessageAsync)(_videoDownload.MSG_EVENT_PAGE_INJECTION_ENABLED,{url:location.href}).then(function(n){var e=n.enabled;e&&getInjector()&&(0,_message.sendMessageAsync)(_videoDownload.MSG_EVENT_VIDEO_DOWNLOAD_CRAWL_URL,{url:location.href}).then(processVideoData)});


},{"3":3,"4":4,"5":5}],2:[function(require,module,exports){
"use strict";function defer(){var e=void 0,r=void 0,n=new Promise(function(n,o){e=n,r=o});return{resolve:function(r){e(r)},reject:function(e){r(e)},promise:n}}exports.defer=defer;


},{}],3:[function(require,module,exports){
"use strict";function $(e,o){return e instanceof HTMLElement?e:(o||document).querySelector(e)}function _$(e,o){return(o||document).shadowRoot.querySelector(e)}function _$$(e,o){return slice.call((o||document).shadowRoot.querySelectorAll(e))}function $$(e,o){return slice.call((o||document).querySelectorAll(e))}function toggleClass(e,o,t){var r=2==arguments.length?e.classList.contains(o):!t;e.classList[r?"remove":"add"](o)}function removeNodeFromParent(e){return e&&e.parentNode?(e.parentNode.removeChild(e),!0):!1}exports.$=$,exports._$=_$,exports._$$=_$$,exports.$$=$$,exports.toggleClass=toggleClass,exports.removeNodeFromParent=removeNodeFromParent;var slice=Array.prototype.slice;


},{}],4:[function(require,module,exports){
"use strict";var MSG_EVENT_VIDEO_DOWNLOAD_CRAWL_URL=exports.MSG_EVENT_VIDEO_DOWNLOAD_CRAWL_URL="VD-crawl-url",MSG_EVENT_VIDEO_DOWNLOAD_CHROME_DOWNLOAD=exports.MSG_EVENT_VIDEO_DOWNLOAD_CHROME_DOWNLOAD="VD-chrome-download",MSG_EVENT_VIDEO_DOWNLOAD_EXTERNAL_CRAWL_URL=exports.MSG_EVENT_VIDEO_DOWNLOAD_EXTERNAL_CRAWL_URL="VD-external-crawl-url",MSG_EVENT_PAGE_INJECTION_ENABLED=exports.MSG_EVENT_PAGE_INJECTION_ENABLED="page-injection-enabled",MSG_EVENT_WOW_DOWNLOAD_IMAGES=exports.MSG_EVENT_WOW_DOWNLOAD_IMAGES="wow-download-images",MSG_EVENT_WOW_IMAGE_DOWNLOAD_FORMAT=exports.MSG_EVENT_WOW_IMAGE_DOWNLOAD_FORMAT="wow-download-image-format";


},{}],5:[function(require,module,exports){
"use strict";function sendMessageAsync(e,r){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=t.noReply,o=t.extId,s={type:e,data:r,sync:!1,noReply:n,d:"req"};if(n)return sendMsg(o,s),Promise.resolve();var c=guid(),d=(0,_defer.defer)();return s.guid=c,deferCache[c]=d,sendMsg(o,s),d.promise["catch"](noop)}function initPort(){deferCache=Object.create(null);try{extPort=chrome.runtime.connect({name:"page:connect"}),extPort.onMessage.addListener(onMsg),extPort.onDisconnect.addListener(function(){disposePort(),setTimeout(initPort,0)})}catch(e){console.log(e)}}function disposePort(){for(var e in deferCache){var r=deferCache[e];r&&r.reject&&r.reject("disconnect")}deferCache=Object.create(null),extPort=null}function onMsg(e){var r=e.guid,t=e.d,n=deferCache[r];if("postTab"===t){var o=bkMsgHandlers[e.type];o&&o(e.data)}else n&&"res"===t&&(e.success?n.resolve(e.data):n.reject(e.error),delete deferCache[r])}function registerMsgHandler(e,r){"function"==typeof r&&(bkMsgHandlers[e]=r)}function sendMsg(e,r){if(e&&r)throw Error("not support external");r&&(extPort?extPort.postMessage(r):chrome.runtime.sendMessage(r))}function noop(){}function guid(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+Date.now()}exports.sendMessageAsync=sendMessageAsync,exports.registerMsgHandler=registerMsgHandler;var _defer=require(2),deferCache=void 0,bkMsgHandlers=Object.create(null),extPort=void 0;"object"==typeof chrome&&chrome.runtime&&chrome.runtime.onMessage&&chrome.runtime.onMessage.addListener(onMsg),window.addEventListener("unload",function(){extPort.disconnect(),disposePort()}),initPort();


},{"2":2}]},{},[1]);
