Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener('DOMContentLoaded', function(){
- setTimeout(function(){
- var country = getCountryCookie(),
- countryTitle = document.querySelector('#job_list .content_header .jSearchSubtitle'),
- countryTitleInner = document.querySelector('.content_header .primary_location'),
- cssRule = '#container.countryRU #right_holder {display:none !important}; .chzn-drop{z-index:99000000} ';
- console.log('---= Dr.Watson is here 2611:1331 =---');
- if (country) {
- magicJS(country);
- console.log('Country Source: Cookies, country is:', country);
- } else if (countryTitle && countryTitle.innerText.toLowerCase() == "russian federation" ||
- countryTitleInner && countryTitleInner.innerText.toLowerCase().includes("russian federation")) {
- magicJS("RU");
- console.log('Country Source: ', (countryTitle) ? 'CountryTitle' : 'CountryTitleInner');
- } else {
- getCountryAjax();
- console.log('Country Source: ipInfo, country is:', country);
- }
- if (document.querySelector('#container')) addCss(cssRule);
- function getCountryAjax() {
- var _askInfo = Date.now();
- ajax('https://ipinfo.io?token=42d65fdffa6d45', 'get', function (obj) {
- var country = (obj && obj.responseText && JSON.parse(obj.responseText)) ? JSON.parse(obj.responseText).country : 'ipInfoFail';
- console.log('currentLocation::: ', country);
- if (country && country != "ipInfoFail") document.cookie = "currentCountry=" + country + "; expires=Mon, 28 Dec 2115 12:00:00 UTC; path=/";
- magicJS(country);
- console.log("|| ipInfo timing:", (Date.now() - _askInfo).toString() + 'ms ||');
- });
- }
- function magicJS(country) {
- if (country == "RU" || (countryTitle && countryTitle.innerText.toLowerCase() == "russian federation") || (countryTitleInner && countryTitleInner.innerText.toLowerCase().includes("russian federation"))) {
- if (document.querySelector('#container')) document.querySelector('#container').classList.add('countryRU');
- }
- if (countryTitleInner && (country == "RU" || countryTitleInner.innerText.toLowerCase().includes("russian federation"))) {
- var $applyBtn = document.querySelector('[id*="apply_btn"]'),
- requisitionTitle = document.querySelector('h1.title').innerText,
- requisitionID = document.querySelector('.job_external_id .field_value').innerText,
- //backURL = 'https://medtronic.taleo.net/careersection/2/jobapply.ftl?job=' + requisitionID + '&lang=en',
- backURL = 'https://medtronic.taleo.net/careersection/2/jobapply.ftl?job=' + requisitionID,
- $applyAnchor = document.createElement('a');
- $applyAnchor.classList.add("primary_btn");
- $applyAnchor.innerHTML = $applyBtn.innerHTML;
- $applyBtn.parentNode.insertBefore($applyAnchor, $applyBtn);
- $applyBtn.parentNode.removeChild($applyBtn);
- //backURL = window.location.href.toString();
- //backURL = backURL.replace('jobs/', 'flow/');
- $applyAnchor.href = encodeURI('https://medtronic.talentsys.ru/gateway.html?recTitle=' + requisitionTitle + '&requisition=' + requisitionID + '&redirect=' + backURL);
- $applyAnchor.style.marginRight = '10px';
- $applyAnchor.target = "_blank";
- }
- }
- function getCountryCookie() {
- var out = {},
- cooks = document.cookie.split('; ');
- cooks.forEach(function (it) {
- var el = it.replace(' ', '').split('=');
- out[el[0]] = el[1];
- });
- //console.log('JSONed cooks', out);
- return out.currentCountry ? out.currentCountry : null;
- }
- function addCss(rule) {
- let css = document.createElement('style');
- css.type = 'text/css';
- if (css.styleSheet) css.styleSheet.cssText = rule; // Support for IE
- else css.appendChild(document.createTextNode(rule)); // Support for the rest
- document.getElementsByTagName("head")[0].appendChild(css);
- }
- function ajax(url, method, callback) {
- var obj, params = null;
- try {
- obj = new XMLHttpRequest();
- } catch (e) {
- try {
- obj = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try {
- obj = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- alert("Your browser does not support Ajax.");
- return false;
- }
- }
- }
- obj.onreadystatechange = function () {
- if (obj.readyState == 4) {
- callback(obj);
- }
- };
- obj.open(method, url, true);
- obj.send(params);
- return obj;
- }
- }, 1000);
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement