-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathin_page.js
1 lines (1 loc) · 29.4 KB
/
in_page.js
1
!function e(t,r,n){function o(a,c){if(!r[a]){if(!t[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=r[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,r,n)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,t,r){(function(t){(function(){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=document.createElement("A");i.href=window.location.href;var a,c,l,s,u,d=e("./in_page/in_page_flags");t.comms=chrome.runtime.connect({name:"inPage"}),i.hostname.match("(^|.)youtube.")&&(window.onpopstate=function(){window.location.reload()});var f=chrome.extension.getURL("blocked-yt-avatar.png"),m=function(){r(document.querySelectorAll("#avatar")).forEach((function(e){r(e.getElementsByTagName("img")).forEach((function(e){e.src!==f&&(e.src=f)}))}))},h=function(){var e=document.createElement("A");if(e.href=window.location.href,e.hostname.match(/(^|\.)youtube\./)&&(e.pathname.match(/^\/user\/[^\/\?]+$/)||e.pathname.match(/^\/channel\/[^\/\?]+$/)||e.pathname.match(/^\/c\/[^\/\?]+$/)||e.pathname.match(/\/featured$/)||e.pathname.match(/^\/@[^\/\?]+$/))){var t=document.getElementsByTagName("video");if(t.length>0)for(var r in t)if("function"==typeof t[r].pause){t[r].paused||(console.debug("[LS Filter] pause autoplay"),t[r].pause());var n=t[r].closest("ytd-channel-video-player-renderer");n&&"none"!==n.style.display&&(console.debug("[LS Filter] hide autoplay container"),n.style.display="none")}}},y=function(){var e=document.getElementById("video-preview-container");e&&e.remove();var t=document.getElementsByTagName("ytd-miniplayer");t.length>0&&t[0].remove();var r=document.getElementById("video-preview");r&&r.remove(),document.querySelectorAll("div#mouseover-overlay").forEach((function(e){e.remove()})),document.querySelectorAll("div#hover-overlays").forEach((function(e){e.remove()}))},p=[];function v(){var e=window.location.href;e.match(/\/embed\//)&&(p.includes(e)||(p.push(e),console.debug("[LS Filter] embed detected ->",e),comms.postMessage({action:"scoreVideo",url:e})))}function g(){var e=window.location.href;if(e.match(/\/shorts\//)&&!p.includes(e)){p.push(e);var t=e.split("/"),r="https://www.youtube.com/watch?v=".concat(t[t.length-1]);console.debug("[LS Filter] shorts detected ->",r),comms.postMessage({action:"scoreVideo",url:r})}}var b=function(){var e=document.getElementById("read-only-flash-notice"),t=0,r=setInterval((function(){var n=100-++t;n<1?(clearInterval(r),e.style.display="none"):e.style.opacity=(n/100).toString()}),15);clearTimeout(window.readOnlyNoticeTimeout)},w=function(e){e.stopPropagation(),e.preventDefault(),comms.postMessage({action:"override",rg:_.id})};var E=function(e){e.preventDefault(),e.stopPropagation(),console.log("PARAMS ",_);var t=document.getElementById("code").value;comms.postMessage({action:"lockoutOverride",rg:_.id,code:t})};var S,k,I=function(e){return e.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)},x=function(){var e=document.getElementById("submitReview");e&&(document.getElementById("reviewButton").className+=" hidden",e.parentElement.className=e.parentElement.className.replace(/hidden/,""),e.onclick=T)},T=function(e){e.preventDefault(),e.stopPropagation();var t=!0,r=document.getElementById("reviewReason");r.value&&""!==r.value.trim()||(r.value="",r.placeholder="Reason (required)",t=!1);var n=document.getElementById("reviewEmail");n.value&&""!==n.value&&!I(n.value)&&(n.value="",n.placeholder="Email (valid or blank)",t=!1),t&&(comms.postMessage({action:"submitReview",name:document.getElementById("reviewName").value.trim(),email:document.getElementById("reviewEmail").value,reason:r.value.trim(),blockInfo:S}),document.getElementById("submitReview").parentElement.className+=" hidden")},_={};var O=[],q=!1;function B(){if(q){console.debug("[LS Filter] scanned image count:",O.length);for(var e=document.getElementsByTagName("a"),t=0;t<e.length;t++){var r=void 0,n=e[t],o=unescape(unescape(n.href));if(o.match(/imgres\?imgurl=/)||o.match(/google\.com\/url\?/)){var i=n.children[1]||n.children[0];i&&(""!==i.id?r=i.id:(r=Math.random().toString(36).substring(2,15),i.id=r),O.includes(r)||(O.push(r),comms.postMessage({action:"scoreImage",imgId:r,imgUrl:o})))}}}q=!1,setTimeout(B,3e3)}function L(){console.log("[googlePicker] monitoring ->",i.href),document.addEventListener("queryReq",(function(e){if(e.detail)try{var t=JSON.parse(e.detail);if(t.length>0&&"qreq"===t[0]){var r=t[t.length-1][3];console.log("[googlePicker] queryReq ->",r),comms.postMessage({action:"scorePickerQuery",query:"https://www.google.com/search?q="+r})}}catch(e){console.debug("[googlePicker] queryReq ->",e)}})),document.addEventListener("queryResp",(function(e){if(e.detail)try{var t,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return c=e.done,e},e:function(e){l=!0,a=e},f:function(){try{c||null==r.return||r.return()}finally{if(l)throw a}}}}(e.detail.matchAll(/\[\["(https:\/\/encrypted-tbn0.gstatic.com[^,"]+)"[^\[]+[^\]]+\],"(http[^"]+)/g));try{for(r.s();!(t=r.n()).done;){var o=t.value;console.log("[googlePicker] queryResp ->",o[1],o[2]),comms.postMessage({action:"scorePickerImage",imgId:decodeURI(o[1]),imgUrl:decodeURI(o[2])})}}catch(e){r.e(e)}finally{r.f()}}catch(e){console.debug("[googlePicker] queryResp ->",e)}}));var e=document.createElement("script");e.innerHTML="\n const open = window.XMLHttpRequest.prototype.open;\n const send = window.XMLHttpRequest.prototype.send;\n function openReplacement(method, url, async, user, password) { \n this._url = url;\n return open.apply(this, arguments);\n }\n function sendReplacement(data) {\n this.addEventListener('load', function() {\n const rEvent = new CustomEvent('queryResp', {detail: this.responseText});\n document.dispatchEvent(rEvent);\n });\n const qEvent = new CustomEvent('queryReq', {detail: data});\n document.dispatchEvent(qEvent);\n return send.apply(this, arguments);\n }\n window.XMLHttpRequest.prototype.open = openReplacement; \n window.XMLHttpRequest.prototype.send = sendReplacement;\n ",document.head.appendChild(e)}function R(e){void 0!==e.blockPageURI&&function(e,t,r){if(window.location.href.match(e)||window.location.href.match(t)){var n=JSON.parse(document.getElementById("translations").value),o=r||"en";void 0===n[o]&&(o="en"),document.querySelectorAll("[data-translation]").forEach((function(e){e.hasAttribute("placeholder")?e.setAttribute("placeholder",n[o][e.dataset.translation]):e.innerText=n[o][e.dataset.translation]}));for(var i=window.location.search.replace(/\?/,"").split("="),a=0,c=i.length;a<c;a++)_[i[0]]=i[1];_.id&&comms.postMessage({action:"blockInfo",rg:_.id,locale:o})}}(e.blockPageURI,e.s3BlockScreen,e.locale),function(e,t){if(Array.isArray(t)||(t=[]),e&&e.length>0){if(t.includes(i.hostname))return void console.debug("[LS Filter] flag ignore:",i.href);var r,n=new d(i);n.Initialize(e,t).then((function(){void 0!==r&&clearInterval(r);var e=function(){try{window.location.href!==i.href&&(i.href=window.location.href);var e=n.Scan();Array.isArray(e)&&e.length>0&&n.Report(e)}catch(e){console.error(e)}};r=setInterval(e,5e3),e()})).catch(console.error)}}(e.terms,e.ignoredSites),e.ytSettings&&function(e){if(void 0!==e){var t=document.createElement("STYLE");if(t.type="text/css",t.innerText="",e.hide_sidebar&&(console.debug("[LS Filter] hide sidebar"),t.innerText+=".watch-sidebar, .ytd-watch-next-secondary-results-renderer {display: none !important;}\n"),e.hide_comments&&(console.debug("[LS Filter] hide comments"),t.innerText+="#watch-discussion, .watch-discussion, ytd-comments {display: none !important;}\n"),""!==t.innerText){var r=document.getElementsByTagName("head");r&&r.length>0&&(r=r[0]).append(t)}e.disable_chan_autoplay&&(console.debug("[LS Filter] disable autoplay"),void 0!==a&&(clearInterval(a),a=void 0),h(),a=setInterval(h,1e3)),e.block_thumbnails&&(console.debug("[LS Filter] block thumbnails"),void 0!==c&&(clearInterval(c),c=void 0),m(),c=setInterval(m,1e3)),console.debug("[LS Filter] hide miniplayers"),void 0!==l&&(clearInterval(l),l=void 0),y(),l=setInterval(y,1e3),void 0!==s&&(clearInterval(s),s=void 0),s=setInterval(v,1e3),void 0!==u&&(clearInterval(u),u=void 0),u=setInterval(g,1e3)}}(e.ytSettings),e.readOnly&&function(e){if(!(document.documentElement&&document.documentElement.clientHeight<250)){var t=document.createElement("div");t.id="read-only-flash-notice",t.style.display="block",t.style.position="fixed",t.style.top="16px",t.style.right="16px",t.style.background="#343d47",t.style.borderRadius="4px",t.style.boxShadow="0 2px 4px rgba(0,0,0,0.25)",t.style.color="#ffffff",t.style.maxWidth="400px",t.style.overflow="hidden",t.style["z-index"]="2147483647";var r=document.createElement("div");r.style.float="left",r.style.padding="16px";var n=document.createElement("div");n.innerText=e;var o=document.createElement("div");o.style.borderLeftStyle="solid",o.style.borderLeftWidth="1px",o.style.borderColor="#505861",o.style.float="left";var i=document.createElement("a");i.style.color="#ffffff",i.style.cursor="pointer",i.style.display="block",i.style.padding="16px",i.style.textDecoration="none",i.innerText="Dismiss",i.addEventListener("click",b),i.addEventListener("mouseenter",(function(e){e.target.style.textDecoration="underline"})),i.addEventListener("mouseleave",(function(e){e.target.style.textDecoration="none"})),r.appendChild(n),t.appendChild(r),o.appendChild(i),t.appendChild(o),document.getElementsByTagName("body")[0].appendChild(t),document.getElementById("read-only-flash-notice").style.setProperty("font-size","16px","important"),window.readOnlyNoticeTimeout=setTimeout((function(){b()}),8e3)}}("This website is in read only mode."),i.href.match(/docs\.google\.com\/picker\/v2/)&&L()}comms.onMessage.addListener((function(e){switch(console.debug("[LS Filter] in_page comms message",e),e.action){case"settings":R(e);break;case"imageScan":q=!0,B(),new MutationObserver((function(e){e.length>0&&(q=!0)})).observe(document,{childList:!0,subtree:!0});break;case"imageScored":!function(e){if(e.blocked){console.debug("[LS Filter] image blocked",e.imgId);var t=document.getElementById(e.imgId);t&&t.src&&(t.src=chrome.extension.getURL("blocked-image-search.png"))}}(e);break;case"videoScored":!function(e){if(e.blocked){var t='<img src="'.concat(chrome.extension.getURL("blocked-image-search.png"),'" style="width: 100%;">');if(console.debug("[LS Filter] video blocked ->",e.url),window.location.href.match(/\/shorts\//)){var r=document.querySelectorAll("[is-active]");if(r&&r.length>1)document.getElementById(r[1].id).innerHTML=t}window.location.href.match(/embed\//)&&(document.body.innerHTML=t)}}(e);break;case"pickerQueryScored":(r=e).redirect&&(console.debug("[handlePickerQuery] blocked"),window.location.href=r.redirect);break;case"pickerImageScored":!function(e){if(e.blocked){var t=e.imgId.replace(/\\u003d/,"=").replace(/\\u0026/,"&");console.debug("[handlePickerImage] blocked ->",t),document.querySelectorAll('img[src="'.concat(t,'"]')).forEach((function(e){e.src=chrome.extension.getURL("blocked-image-search.png"),e.parentNode.parentNode.setAttribute("data-item","")}))}}(e);break;case"blockInfo":!function(e){if(S=e,i.href=e.url,window.location.href.match(/^chrome-extension:/)){if(e.bs_name&&(document.getElementById("blockScreen-customSchoolName").innerHTML=e.bs_name),e.bs_body&&(document.getElementById("blockScreen-customBodyText").innerHTML=e.bs_body),e.bs_footer&&(document.getElementById("blockScreen-customFooterText").innerHTML=e.bs_footer),e.bs_color){for(var t=document.getElementsByClassName("svgAccessBlocked-paths"),r=0;r<t.length;r++)t[r].style.stroke=e.bs_color;for(var n=document.querySelectorAll(".blockScreen-stripe,.lockoutScreen-stripe"),o=0;o<n.length;o++)n[o].style.background=e.bs_color}e.ls_cat&&(k=e.ls_cat)}if(!k){var a=JSON.parse(document.getElementById("categories").value);k=a[e.catId]}document.getElementById("host").innerText=e.host||i.hostname,document.getElementById("username").innerText=e.username,document.getElementById("ip").innerText=e.ip;var c=e.locale,l=JSON.parse(document.getElementById("translations").value),s="",u=document.getElementsByClassName("blockScreen-stripe")[0];switch(e.reason){case"yt":s=l[c].org_youtube_rules;break;case"url":s=l[c].custom_block_list;break;case"ext":s=l[c].file_ext_blocked;break;case"wz":s=l[c].webzone_rule;break;case"search":s=l[c].search_term_used;break;case"lockout":var d=document.getElementById("override");return document.getElementsByClassName("blockScreen")[0].className+=" lockoutScreen",document.getElementById("minutes").innerText=e.lockoutTime,d.className=d.className.replace(/hidden/,""),void(d.onclick=E);case"off":u&&(u.innerText=l[c].access_disabled,u.style["font-size"]="145%",u.style["font-weight"]="bolder",u.style.color="#FFF");break;case"parent":u&&(u.innerText="Parental Pause Active",u.style["font-size"]="145%",u.style["font-weight"]="bolder",u.style.color="#FFF");break;default:s="".concat(l[c].categorized_as," ").concat(k)}var f=document.getElementById("reason");f&&(f.innerText=s);var m=document.getElementById("override-time");if(m&&(m.style.display="none"),e.overridable){if(e.override&&e.override.timeout){var h=document.getElementById("override-duration");h&&(h.innerText=e.override.timeout/6e4),m&&(m.style.display="block")}var y=document.getElementById("override");y&&(y.className=y.className.replace(/hidden/,""),y.onclick=w)}if(e.reviewable&&["cat","yt","url","search"].includes(e.reason)){var p=document.getElementById("reviewButton");p&&(p.className=p.className.replace(/hidden/,""),p.onclick=x,I(e.username)&&(document.getElementById("reviewEmail").value=e.username))}}(e.blockInfo);break;case"override":(t=e).url?window.location=t.url:t.err&&alert(t.err);break;case"lockoutOverride":!function(e){e.lockoutRedirectUrl?window.location=e.lockoutRedirectUrl:e.err&&alert(e.err)}(e)}var t,r})),comms.postMessage({action:"settings",href:window.location.href})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./in_page/in_page_flags":6}],2:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="facebook",t.hostname.match(/\.?facebook\.com$/i)&&(this.disabled=!1)},(t=[{key:"GatherIntent",value:function(){if(!this.disabled){var e=[];return document.querySelectorAll('[data-text="true"]').forEach((function(t){e.push(t.innerText)})),e}}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}],3:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="gmail",t.hostname.match(/mail\.google\.com$/i)&&(this.disabled=!1)},(t=[{key:"GatherIntent",value:function(){if(!this.disabled){var e=[];return document.querySelectorAll('[role="textbox"]').forEach((function(t){e.push(t.innerText)})),e}}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}],4:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="google_doc",t.hostname.match(/docs\.google\.com$/i)&&(this.disabled=!1)},(t=[{key:"GatherIntent",value:function(){if(!this.disabled)return[document.body.innerText]}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}],5:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="google",t.hostname.match(/^(www\.)?google\.com$/i)&&(this.disabled=!1)},(t=[{key:"GatherIntent",value:function(){if(!this.disabled){var e=[];return document.querySelectorAll('form[action="/search"] input[type="text"][name="q"]').forEach((function(t){e.push(t.value)})),e}}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}],6:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=["change","keyup"],c=e("./facebook_flags"),l=e("./twitter_flags"),s=e("./gmail_flags"),u=e("./google_flags"),d=e("./google_doc_flags"),f=e("./ms_office_flags"),m=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("url object required");this.UrlObject=t,this.terms=[],this.lastBodyText="",this.target={},this.initialized=!1,this.reportedTerms={},this.modules=[];var r=new c(t);r.disabled||this.modules.push(r);var n=new l(t);n.disabled||this.modules.push(n);var o=new s(t);o.disabled||this.modules.push(o);var i=new u(t);i.disabled||this.modules.push(i);var a=new d(t);a.disabled||this.modules.push(a);var m=new f(t);m.disabled||this.modules.push(m)},(t=[{key:"DOMExtractAndScan",value:function(e){var t,r,n=this;if(void 0===e.target)throw new Error("event has no target");switch(e.type){case"scan":r="GatherIntent";break;default:r=e.target.tagName.toLowerCase()}switch(r){case"input":var o=e.target.type||"text";if("password"===(o=o.toLowerCase()))break;t=[e.target.value];break;case"textarea":t=[e.target.value];break;case"div":if(e.target.attributes&&e.target.attributes.role&&"textbox"===e.target.attributes.role.value){t=[e.target.innerText];break}default:t=[],this.modules.forEach((function(e){if("function"==typeof e.GatherIntent){var r=e.GatherIntent();"string"==typeof r?t.push(r):Array.isArray(r)&&(t=t.concat(r))}}))}void 0!==t&&t.forEach((function(e){if(""===e)n.target.RelayFlaggedTerms={};else{void 0===n.target.RelayFlaggedTerms&&(n.target.RelayFlaggedTerms={});var t=n.Scan(e),r=[];t.forEach((function(e){var t=e[0],o=e[1];e[2]=!0,void 0===n.target.RelayFlaggedTerms[t]?(n.target.RelayFlaggedTerms[t]=o,r.push(e)):n.target.RelayFlaggedTerms[t]<o&&(e[1]=o-n.target.RelayFlaggedTerms[t],n.target.RelayFlaggedTerms[t]+=e[1],r.push(e))})),r.length>0&&n.Report(r)}}))}},{key:"HandleDOM_change",value:function(e){if(void 0===e)throw new Error("event required");if("change"!==e.type)throw new Error("event must be a change event");if(void 0===e.target)throw new Error("event has no target");void 0!==e.target.tagName&&(this.ShouldIgnore()||this.DOMExtractAndScan(e))}},{key:"HandleDOM_keyup",value:function(e){if(void 0===e)throw new Error("event required");if("keyup"!==e.type)throw new Error("event must be a keyup event");if(void 0===e.target)throw new Error("event has no target");void 0!==e.target.tagName&&(this.ShouldIgnore()||this.DOMExtractAndScan(e))}},{key:"HandleDOM",value:function(e){if(void 0===e)throw new Error("event required");if(-1===a.indexOf(e.type))throw new Error("unsupported event type - ".concat(e.type));"function"==typeof this["HandleDOM_".concat(e.type)]&&this["HandleDOM_".concat(e.type)](e)}},{key:"BindToDOM",value:function(){var e=this;document.addEventListener("change",this.HandleDOM.bind(this)),document.addEventListener("keyup",this.HandleDOM.bind(this)),setInterval((function(){e.DOMExtractAndScan(new Event("scan"))}),1e3)}},{key:"Initialize",value:function(e,t){var r=this;if(!Array.isArray(e))throw new Error("terms required");if(!Array.isArray(t))throw new Error("ignoredSites required");return new Promise((function(n){r.terms=[],e.forEach((function(e){var t={term:e},n=e.replace(/[\]{}?^$().*\\+|[]/g,"\\$&");n=(n=n.replace(/\\\*/g,".*")).replace(/\\\?/g,"."),t.regex=new RegExp("\\b"+n+"\\b","gi"),r.terms.push(t)})),r.ignoredSites=t,r.initialized=!0,r.BindToDOM(),n()}))}},{key:"SiteMatchers",value:function(){var e=this;if(void 0!==this.siteMatchers)return this.siteMatchers;if(!Boolean(this.initialized))throw new Error("Initialization required");try{this.siteMatchers=[],this.ignoredSites.forEach((function(t){if("object"===n(t))Boolean(t.r)&&e.siteMatchers.push(new RegExp(t.url,"i"));else if("string"==typeof t)if(t.match(/^([\w\d-]{1,63}\.)+[\w\d-]{1,63}$/i))e.siteMatchers.push(t.toLowerCase().split("."));else{var r=t.replace(/[\]{}?^$().*\\+|[]/g,"\\$&");r=r.replace(/\\\*/g,".*"),e.siteMatchers.push(new RegExp("^"+r+"$","i"))}}))}catch(e){throw this.siteMatchers=void 0,e}return this.siteMatchers}},{key:"ShouldIgnore",value:function(){var e=this;if(!Boolean(this.initialized))throw new Error("Initialization required");var t=!1,r=this.UrlObject.hostname.toLowerCase().split(".");return this.SiteMatchers().some((function(n){if("[object Array]"===Object.prototype.toString.call(n)){var o=n.length,i=n.length;if(o<=i){for(var a=0;a<o;a++)if(n[o-1-a]!==r[i-1-a])return!1;return t=!0,!0}}else if(e.UrlObject.href.match(n))return t=!0,!0})),t}},{key:"Scan",value:function(e){var t=this,r=[],n="",o=!1;if(!Boolean(this.initialized))throw new Error("Initialization required");if(void 0!==e&&"string"!=typeof e)throw new Error("string required");if(this.ShouldIgnore())return r;if(void 0===this.reportedTerms[this.UrlObject.href]&&(this.reportedTerms[this.UrlObject.href]={}),void 0===e){if((n=document.body.innerText)===this.lastBodyText)return}else n=e,o=!0;return this.terms.forEach((function(e){var i=n.match(e.regex);null!=i&&i.length>0&&(void 0===t.reportedTerms[t.UrlObject.href][e.term]?(r.push([e.term,i.length]),t.reportedTerms[t.UrlObject.href][e.term]=i.length):o&&r.push([e.term,i.length]))})),r}},{key:"Report",value:function(e){if(!Array.isArray(e))throw new Error("flags must be an array");0!==e.length&&comms.postMessage({action:"flags",flags:{href:this.UrlObject.href,hits:e}})}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=m},{"./facebook_flags":2,"./gmail_flags":3,"./google_doc_flags":4,"./google_flags":5,"./ms_office_flags":7,"./twitter_flags":8}],7:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="ms_office",this.hostname=t.hostname.toLowerCase(),this.disabled=this.setDisabled()},(t=[{key:"GatherIntent",value:function(){if(!this.disabled)return[document.body.innerText]}},{key:"setDisabled",value:function(){var e=this.hostname.split("."),t=e.length;if(!e[t-2])return!0;var r=e[t-2],n=e[t-3];switch("co"===r&&"uk"===e[t-1]&&(r=e[t-3],n=e[t-4]),r){case"live":case"office":case"office365":break;default:return!0}switch(n){case"officeapps":case"outlook":return!1;default:return!0}}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}],8:[function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}var a=function(){return e=function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw new Error("URL Object required");this.disabled=!0,this.moduleName="twitter",t.hostname.match(/\.?twitter\.com$/i)&&(this.disabled=!1)},(t=[{key:"GatherIntent",value:function(){if(!this.disabled){var e=[];return document.querySelectorAll(".tweet-box.rich-editor").forEach((function(t){e.push(t.innerText)})),e}}}])&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();t.exports=a},{}]},{},[1]);