‘I’m in my mid-40s and two supplements have helped turn my grey hair brown again’

[]
]]]]>]]>]]]]>]]>]]]]>]]> Raven.config(‘https://6b64f5cc8af542cbb920e0238864390a@sentry.io/147999’).install(); ]]]]>]]>]]]]>]]>’I’m in my mid-40s and two supplements have helped turn my grey hair brown again’]]]]>]]>]]]]>]]>]]]]>]]>]]]]>]]>]]]]>]]>]]]]>]]>]]]]>]]>]]]]>]]>GB News
Get free breaking news alerts?’, // (string) a text to display on the popup askLaterButtonText: ‘Maybe later’, // (string) custom text for the “Ask later” button confirmSubscriptionButtonText: ‘Sign up now!’, // (string) custom text for the “Subscribe” button iconUrl: ‘https://assets.rbl.ms/34215656/origin.jpg’, // (string) custom icon URL delay: 2, // (integer) a delay between the page loading and popup appearance retryOffset: 604800, // (integer) an offset in seconds to display the popup again overlay: false, // (boolean) enables page overlaying when popup is displayed position: ‘top’, // (string) position on the page. Possible values: ’top’ | ‘center’ | ‘bottom’ bgColor: ‘#fff’, // (string) popup’s background color borderColor: ‘#0032aa’, // (string) popup’s border color boxShadow: ‘0 3px 6px rgba(0,0,0,0.16)’, // (string) popup’s shadow textColor: ‘#0032AA’, // (string) popup’s text color textSize: ‘inherit’, // (string) popup’s text size fontFamily: ‘inherit’, // (string) popup’s text font subscribeBtnBgColor: ‘#0032aa’, // (string) “Subscribe” button’s color subscribeBtnTextColor: ‘#fff’, // (string) “Subscribe” button text’s color askLaterBtnBgColor: ‘#fff’, // (string) “Ask later” button’s color askLaterBtnTextColor: ‘#0032aa’, // (string) “Ask later” button text’s color theme: ‘material’ // or ‘topbar’. A popup theme, see the details below }, userId: ‘user_id’, tags: { ‘Name’: ‘John Smith’ } }]); }; // Analytics – API call for tracking Pushwoosh.push(function(api) { api.setTags({ ‘Piano Visitor ID’: { operation: ‘increment’, value: pa.getVisitorId, } }) }); ]]]]]]]]>]]]]]]>]]]]>]]>
currentTime); if (document.querySelector(‘.breaking-banner__post’).childNodes.length != 0 && unpublish >= currentTime){ let hasCookie = getCookie(‘hideAlert’), original = window.location.href.split(‘?’)[0], postURL = document.querySelector(“.banner__url”).getAttribute(‘href’).split(‘?’)[0], hasSidebar = document.querySelectorAll(‘.content–with–sidebar’).length, postId = document.querySelector(“.breaking-banner__post .widget”).getAttribute(‘elid’); document.querySelector(‘.breaking-banner__close-btn’).addEventListener(‘click’, ()=>{ document.querySelector(‘.breaking-banner__wrapper’).classList.add(‘hidden’); setCookie(‘hideAlert’, postId) }); document.querySelector(‘.breaking-banner__post .widget__headline-text’).addEventListener(‘click’, ()=>{ setCookie(‘hideAlert’, postId) }); document.querySelector(‘.breaking-banner__post .widget__subheadline-text’).addEventListener(‘click’, ()=>{ setCookie(‘hideAlert’, postId); }); if (hasSidebar 0) { c_start = document.cookie.indexOf(c_name + “=”); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(“;”, c_start); if (c_end == -1) { c_end = document.cookie.length; } return unescape(document.cookie.substring(c_start, c_end)); } } return “”; } function setCookie(cname, cvalue) { document.cookie = cname + “=” + cvalue + “; path=/”; } ]]]]]]]]>]]]]]]>]]]]>]]>]]]]>]]>–>paragraph number ${i}` return div; } insertAfter(5, “ad-wrapper”); //document.querySelector(‘.ad-wrapper.bottom-ad’).append(createDiv(‘ ‘)); ]]]]]]]]>]]]]]]>]]]]>]]>]]]]]]>]]]]>]]>` video.after(div); ]]]]>]]>]]]]]]>]]]]>]]> { const left = sec_nav_left_btn.cloneNode(true); const right = sec_nav_right_btn.cloneNode(true); item.append(left); item.append(right) }); REBELMOUSE_STDLIB.createElementChangeListener(‘.primary–nav__arrow’, function (item) { buttonNextPrevVisiblity(0, item, pri_nav, “”); item.addEventListener(“click”, function () { const scroll_distance = item.classList.contains(‘left’) ? -(pri_nav.clientWidth) : pri_nav.clientWidth; pri_nav.scrollBy({ left: scroll_distance, behavior: ‘smooth’ }); buttonNextPrevVisiblity(770,item,pri_nav,item.classList.contains(‘left’)?”left”:”right”) }) }) REBELMOUSE_STDLIB.createElementChangeListener(‘.secondary–nav .secondary–nav__arrow’, function (item) { const secondary_nav = item.closest(‘.secondary–nav’).querySelector(‘.list’); if (secondary_nav) { buttonNextPrevVisiblity(0, item, secondary_nav, item, “”); } item.addEventListener(“click”, function () { if (secondary_nav) { const scroll_distance = item.classList.contains(‘left’) ? -calculateScrollDistance(secondary_nav) : calculateScrollDistance(secondary_nav); secondary_nav.scrollBy({ left: scroll_distance, behavior: ‘smooth’ }); buttonNextPrevVisiblity(770, item, secondary_nav, item.classList.contains(‘left’) ? “left” : “right”); } }); }); function calculateScrollDistance(secondary_nav) { const navLeft = secondary_nav.getBoundingClientRect().left; window.nav_leftttt = secondary_nav; const list = secondary_nav.querySelectorAll(‘a’); const navWidth = secondary_nav.clientWidth; let scroll_distance = 0; let j = 0; while (j < list.length) { //debugger const item = list[j++]; const itemWidth = item.clientWidth; const itemLeft = item.getBoundingClientRect().left; if (itemWidth + 20 + scroll_distance = navLeft && itemLeft + 2 navWidth) { break; } } return scroll_distance; } function buttonNextPrevVisiblity(timeOffset, btn, scrolling_item, clicked) { //console.log('scrolling item scroll - ', scrolling_item.scrollWidth); if (scrolling_item.scrollWidth { if (btn.classList.contains('left')) { //console.log('scroll left - ', scrolling_item.scrollLeft); scrolling_item.scrollLeft > 0 ? btn.classList.remove(“hidden”) : btn.classList.add(“hidden”); } if (btn.classList.contains(‘right’)) { if (scrolling_item.scrollWidth <= scrolling_item.clientWidth + scrolling_item.scrollLeft + 5) { btn.classList.add("hidden"); } else { btn.classList.remove("hidden"); } } if (clicked == "left") { btn.nextElementSibling.classList.remove("hidden"); } if (clicked == "right") { btn.previousElementSibling.classList.remove("hidden") } }, timeOffset); } }); window.REBELMOUSE_TASKS_QUEUE.push(function(){ REBELMOUSE_STDLIB.createElementChangeListener('.show-only-if-post-present', function (item) { if (!item.querySelector('.widget')) { item.classList.add('hidden'); if(item.nextSibling.classList.contains('ad--placeholder')){ item.nextSibling.remove(); } } }); REBELMOUSE_STDLIB.createElementChangeListener('.show-only-if-four-post-present', function (item) { if (item.querySelectorAll('.widget').length { const preDefinedInfo = document.querySelector('.js-all-tags'); let allTags = `${preDefinedInfo.dataset.tags.replace(/[[]']+/g,'')}`; let primarySectionTitle = preDefinedInfo.dataset.contentSection; let postAuthor = preDefinedInfo.dataset.author; let postType = preDefinedInfo.dataset.contentType; let cd1 = preDefinedInfo.dataset.cd1; let cd2 = preDefinedInfo.dataset.cd2; let cd9 = preDefinedInfo.dataset.cd9; let cd11 = window.matchMedia('(display-mode: standalone)').matches ? 'pwa' : 'web'; console.log(cd11); let cd12 = preDefinedInfo.dataset.cd12; let cd13 = preDefinedInfo.dataset.cd13; let cd14 = preDefinedInfo.dataset.cd14; let cd15 = preDefinedInfo.dataset.cd15; let cd16 = preDefinedInfo.dataset.cd16; let cd17 = preDefinedInfo.dataset.cd17; let cd18 = preDefinedInfo.dataset.cd18; let cd19 = document.referrer.split("/")[2] || 'not set'; let cd23 = 'not set'; let cd25 = window.navigator.userAgent; const getInfo = (string) => string.split(”:’)[1].replace(/[&#,+()$~%.'”*?{}]/g, ”).trim(); const passDataToTp = (type, data) => tp.push([type, data]); const passCustomDataToTp = (name, data) => tp.push([‘setCustomVariable’, name, data]); primarySectionTitle = getInfo(primarySectionTitle); passDataToTp(‘setContentSection’, primarySectionTitle); postAuthor = getInfo(postAuthor); passDataToTp(‘setContentAuthor’, postAuthor); postType = getInfo(postType); passCustomDataToTp(‘content_type’, postType); cd1 = getInfo(cd1); passCustomDataToTp(‘cd1’, cd1); cd2 = getInfo(cd2); passCustomDataToTp(‘cd2’, cd2); cd9 = getInfo(cd9); passCustomDataToTp(‘cd9’, cd9); passCustomDataToTp(‘cd11’, cd11); cd12 = getInfo(cd12); passCustomDataToTp(‘cd12’, cd12); cd13 = getInfo(cd13); passCustomDataToTp(‘cd13’, cd13); cd14 = getInfo(cd14); passCustomDataToTp(‘cd14’, cd14); cd15 = getInfo(cd15); passCustomDataToTp(‘cd15’, cd15); cd16 = getInfo(cd16); passCustomDataToTp(‘cd16’, cd16); cd17 = getInfo(cd17); passCustomDataToTp(‘cd17’, cd17); cd18 = getInfo(cd18); passCustomDataToTp(‘cd18’, cd18); passCustomDataToTp(‘cd19’, cd19); passCustomDataToTp(‘cd23’, cd23); passCustomDataToTp(‘cd25’, cd25); return allTags.length ? passDataToTp(‘setTags’, allTags) : false; } addInfoToTP(); });]]]]]]]]>]]]]]]>]]]]>]]> { debug(‘removed event listener: ‘ + tcdata.listenerId); }, tcdata.listenerId); debug(‘tcloaded: loading Outbrain’); addScript(); } else if (tcdata.eventStatus === ‘cmpuishown’) { // call code when cmp message is shown debug(‘cmpuishown’); } } }); REBELMOUSE_STDLIB.createElementChangeListener(‘.sidebar–column .by-outbrain’, function(item) { // Onload orientation const portrait = window.matchMedia(“(orientation: portrait)”); // Logic for showing/hiding Outbrain Ad container const checkLoadForOutbrain = function() { const screenHeight = document.documentElement.clientHeight; if(screenHeight = 850) { return item.style.minHeight=”350px”; } return item.style.maxHeight=”195px”; } // Check height on load checkLoadForOutbrain(); // Orientation change listener portrait.addEventListener(“change”, function(e) { // Check height on orientation change checkLoadForOutbrain(); }) }) function debug(message) { if (DEBUGGING) console.log(‘[ContentIgnite & Outbrain]: ‘+message); } }); }); window.REBELMOUSE_ACTIVE_TASKS_QUEUE.push(function(){ fetch(‘https://gbnews-s3.s3.amazonaws.com/weather-data.rss’) .then(response => response.text()) .then(str => new window.DOMParser().parseFromString(str, “text/xml”)) .then(data => { console.log(data); var items = data.querySelectorAll(“item title”); var item_count=items.length-1; var count=1; var placeholder=document.querySelector(‘.weather–update’); var weather_data=items[0].textContent.trim().split(‘,’); placeholder.innerHTML=`${weather_data[0]}${weather_data[2]}℃`; window.setInterval(function(){ weather_data=items[count].textContent.trim().split(‘,’); placeholder.innerHTML=`${weather_data[0]}${weather_data[2]}℃`; count= count==item_count? 0 : count+1; },7000) }); // link to /weather var els = document.getElementsByClassName(“weather–update”); for(var i = 0, x = els.length; i < x; i++) { els[i].onclick = function(){ window.location.href = "/weather" } } }); window.REBELMOUSE_ACTIVE_TASKS_QUEUE.push(function(){ var pri_nav = document.querySelector('.navbar .nav').cloneNode(true); var hamburger = document.createElement('div'); const searchNavItem = `Search` const searchForMenu = ` our community rules.’; // Viafoura // Make vfQ available or use existing one if already loaded window.vfQ = window.vfQ || []; window.vfQ.push(() => { // Viafoura is loaded and window.vf is available window.vf.$subscribe(‘commenting’, ‘loaded’, function(el) { var headings = el.getElementsByClassName(“vf-comment-header__heading”) if (headings.length) { headings[0].innerHTML = COMMENTS_HEADING; } if (window.location.href.includes(“https://www.gbnews.com/watch/live”)) { let featComments = el.getElementsByClassName(“vf-label-text vf-nav-tab-button__text”); if (featComments.length) { featComments[0].innerHTML = FEATURED_COMMENTS; } } var forms = el.getElementsByClassName(“vf-post-form”); if (forms.length) { var form = forms[0]; let terms = document.createElement(‘p’); terms.classList.add(‘gbn-terms’); terms.innerHTML = COMMENTS_TERMS_HTML; form.after(terms); } }); }); }); }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ window.PianoESPConfig = { id: 407 } tp = window.tp || []; tp.push([“addHandler”, “registrationSuccess”, function (data) { if (data.registration) { var CFields = []; var MAILING_LISTS = [6723, 8457]; tp.pianoId.loadExtendedUser({ extendedUserLoaded: function (data) { console.log(data, “data”) var email = tp.pianoId.getUser() ? tp.pianoId.getUser().email : data.user.email; var API_URL = ‘https://api-esp-eu.piano.io’; var SITE_ID = 392; CFields = data.custom_field_values; for (var i in CFields) { var fieldName = CFields[i].field_name; var fieldValue = CFields[i].value; // assign users to promotions mailing list if tick box is selected if (fieldName == ‘marketingcoms’) { if (fieldValue == ‘true’) { MAILING_LISTS.push(8255); } } }; // console.log(MAILING_LISTS, “mailing_lists”) var body = { email: email, sqids: MAILING_LISTS }; var xhr = new XMLHttpRequest(); xhr.open(‘POST’, API_URL + ‘/tracker/lucid/sub/’ + SITE_ID, true); xhr.setRequestHeader(‘Content-type’, ‘application/json’); xhr.send(JSON.stringify(body)) }, formName: ‘RegistrationFields’ }); }; }]); }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ tp = window.tp || []; window.PianoESPConfig = { id: 407 } // donation and gifting ids let ID_LIST = [“TMQH0UYAUQDM”, “TMC7VE7HG9R2”, “TMYANFFVTS4Q”, “TMROPIB96J4I”, “TM3KPHT4ZF94”, “TMJADYYROV1C”, “TMSP5M2NE6VA”, “TM7P3BWNVVM5”, “TMEPAQAMCH7P”, “TMB4RK0P12MI”, “TMHHDSINJATO”, “TMVATI3WXNBD”, “TMJEJO3K37LC”]; // Loop through the gifitng and donating IDs and add to members-only mailing if term ID is not amongst them for (let i = 0; i { window.dataLayer.push({ ‘event’: ‘pwa_app_install’, }); }); window.addEventListener(‘beforeinstallprompt’, (e) => { window.dataLayer.push({ ‘event’: ‘pwa_app_prompt’, }); }); }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ REBELMOUSE_STDLIB.createElementChangeListener(“.widget__shares”, function(sharesElement){ let currentUrl = window.location.href; console.log(sharesElement); let wppShareUrl = “https://web.whatsapp.com://send?text=” + currentUrl; let wppBtn = document.createElement(“a”); wppBtn.innerHTML = `` wppBtn.setAttribute(“href”, wppShareUrl); wppBtn.setAttribute(“data-track-share”, “WhatsApp”); wppBtn.setAttribute(“class”, “share share-whatsapp-desktop show-buttons”); wppBtn.setAttribute(“rel”, “noopener noreferrer”); wppBtn.setAttribute(“aria-label”, “Share on WhatsApp”); /* let fbShareUrl = “fb-messenger://share/?link=” + currentUrl; let fbBtn = document.createElement(“a”); fbBtn.innerHTML = `` fbBtn.setAttribute(“href”, fbShareUrl); fbBtn.setAttribute(“data-track-share”, “Facebook Messenger”); fbBtn.setAttribute(“class”, “share share-facebook-messenger show-buttons”); fbBtn.setAttribute(“rel”, “noopener noreferrer”); fbBtn.setAttribute(“aria-label”, “Share on Facebook Messenger”); sharesElement.insertBefore(wppBtn, sharesElement.children[2]); sharesElement.insertBefore(fbBtn, sharesElement.children[-1]); */ }) }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ if (!CSS.supports(‘selector(:has(*))’)) { REBELMOUSE_STDLIB.createElementChangeListener(“.widget”, function(post){ const isMemberPost = Boolean(post.querySelector(‘.member-post-label’)); if (isMemberPost) { const label = post.querySelector(‘.member-post-label’); const postContainer = label.closest(‘.widget’); return postContainer.classList.add(‘member’); } return false; //return isMemberPost ? post.classList.add(‘member’) : false; }) } }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ function reAddLead() { console.log(“reAddLead has been called”); let overlayOB = document.querySelector(“.CR_SVM_1.ob-widget.ob-feed-layout”); let overlayOBDesktop = document.querySelector(“.SVD_1.ob-widget.ob-feed-layout”); let photoCaption = document.querySelector(“.photo-caption”); let photoCredit = document.querySelector(“.photo-credit”); // Mobile if (overlayOB) { overlayOB.style.zIndex = “-1”; } // Desktop if (overlayOBDesktop) { overlayOBDesktop.style.zIndex = “-1”; } // Re-add caption and credit if (photoCaption && photoCredit) { photoCaption.style.display = “inline-block”; photoCredit.style.display = “inline”; } } REBELMOUSE_STDLIB.createElementChangeListener(‘#vi-stories-gui-container’, function() { console.log(‘#vi-stories-gui-container – post default’); // remove caption / credit let photoCap = document.querySelector(“.photo-caption”); let photoCred = document.querySelector(“.photo-credit”); if(photoCap && photoCred) { photoCap.style.display = “none”; photoCred.style.display = “none”; } // add eventListener to the OB close button let closeButtonOB = document.getElementById(“vi-stories-close-button”); if (closeButtonOB) { closeButtonOB.addEventListener(“click”, reAddLead); } }) }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ const social_wrapper = document.querySelector(“.widget__shares”); let modalIcon = document.createElement(“button”); // modalIcon.innerText = “Comment”; modalIcon.classList.add(“openModalIcon”); modalIcon.id = “openModalIcon”; // Creating the SVG element let svgElement = document.createElementNS(“http://www.w3.org/2000/svg”, “svg”); svgElement.setAttribute(“width”, “15”); svgElement.setAttribute(“height”, “15”); svgElement.setAttribute(“viewBox”, “0 0 18 18”); svgElement.setAttribute(“fill”, “none”); // Creating the path element within SVG let pathElement = document.createElementNS(“http://www.w3.org/2000/svg”, “path”); pathElement.setAttribute(“d”, “M17.1477 17.2988C16.1007 17.1044 15.124 16.9492 14.1615 16.7344C13.3868 16.5603 12.6872 16.6199 11.9266 16.9147C6.69604 18.9452 1.03825 15.4627 0.424733 9.87132C-0.0839213 5.24579 3.37023 0.987168 7.99037 0.541863C12.5996 0.0981253 16.6031 3.22624 17.2823 7.82511C17.5171 9.41034 17.2995 10.9532 16.6391 12.4161C16.3949 12.9555 16.3417 13.4745 16.4732 14.0484C16.7126 15.1005 16.9145 16.1636 17.1477 17.3004V17.2988Z”); pathElement.setAttribute(“fill”, “white”); // Appending path to the svg element svgElement.appendChild(pathElement); // Appending svgElement to modalIcon button modalIcon.appendChild(svgElement); // Creating comment count span element let spanElement = document.createElement(“span”); spanElement.id = “comment-count-desktop”; modalIcon.appendChild(spanElement); // Create “Comment” span let commentSpan = document.createElement(“span”); commentSpan.id = “comment-span”; commentSpan.innerText = “Comment”; modalIcon.appendChild(commentSpan); // Create “Comments” (with an S) span let commentsSpan = document.createElement(“span”); commentsSpan.id = “comments-span”; commentsSpan.innerText = “Comments”; modalIcon.appendChild(commentsSpan); // Create “now” span let nowSpan = document.createElement(“span”); nowSpan.id = “now”; nowSpan.innerText = “Now!”; modalIcon.appendChild(nowSpan); // Appending modalIcon button to social_wrapper social_wrapper.appendChild(modalIcon); }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ var comments = document.getElementById(‘comments’); var comments_buttons100 = document.querySelectorAll(“#openModalIcon”); var attempts = 0; var engbar = document.querySelector(‘.engbar’); var comments_loaded = false; const max_attempts = 15; const wait_interval = 120; const engbar_h = 80; const margin = 35; const timeout = 2500; const conversation_starter_active = false; const debugging = true; var isUserScrollingUp = false; var lastScrollY = window.scrollY; var scrollingActive = false; // new bit var scrollUpThreshold = 5; comments_buttons100.forEach(button => button.addEventListener(“click”, scrollToComments)); // function 1 // set scrollingActive to true (indicating scrolling is happening) // call smoothScroll() to scroll to the comments section // checks if isUserScrollingUp is true – if yes then aborts and prevents further action happening function scrollToComments() { debug(attempts + ‘ scrollToComments’); var offset = (engbar ? engbar.offsetHeight : engbar_h) + margin; var OB = document.querySelector(‘.OUTBRAIN’); var adBlock = false; scrollingActive = true; smoothScroll(comments, offset).then(() => { if (isUserScrollingUp) { debug(“Scrolling up detected, canceling scrollToComments”); scrollingActive = false; return; } // check for ad blockers if (OB) { adBlock = window.getComputedStyle(OB)?.display === “none”; debug(‘ad blocker ‘ + (adBlock ? ‘detected’ : ‘not detected’)); } // if Viafoura not yet inserted into Outbrain try again if (!comments_loaded && !comments.closest(‘.OUTBRAIN’) && attempts { if (!isUserScrollingUp) { scrollToComments(); } else { scrollingActive = false; } }, Math.floor(wait_interval * (attempts + 1))); } else { // the final attempt debug(“The final attempt”); smoothScroll(comments, offset).then(() => { if (document.querySelector(‘.OUTBRAIN .comments-wrapper’) === null) { debug(‘failed to insert comments into Outbrain’); if (document.querySelector(‘.comments-wrapper .viafoura’)) { document.querySelector(‘.comments-wrapper .viafoura’).style.display = “block”; } if (typeof window.OB_loaded === ‘undefined’ || !window.OB_loaded) { debug(‘Outbrain did not load’); document.querySelector(‘.you-may-like__wrapper’).style.display = “none”; } } debug(‘Comments should now be in view’); // set loaded flag comments_loaded = true; scrollingActive = false; }); } }).catch(err => { scrollingActive = false; debug(err.message); }); } // function 2 // handling of the scroll to comments action // promise is resolved when the target is reached function smoothScroll(elem, offset = 0) { debug(“smoothScroll with offset = ” + offset); const rect = elem.getBoundingClientRect(); let targetPosition = Math.floor(rect.top + window.pageYOffset – offset); window.scrollTo({ top: targetPosition, behavior: ‘smooth’ }); let p = new Promise((resolve, reject) => { const failed = setTimeout(() => { reject(new Error(“Scroll to comments timed out”)); }, timeout); const scrollHandler = () => { if (Math.abs(window.pageYOffset – targetPosition) < 10) { window.removeEventListener("scroll", scrollHandler); clearTimeout(failed); resolve("Target reached, disabling scroll listener"); } if (window.scrollY < lastScrollY) { isUserScrollingUp = true; debug("Scroll up detected"); window.removeEventListener("scroll", scrollHandler); clearTimeout(failed); resolve("User is scrolling up, disabling scroll listener"); } }; if (Math.abs(window.pageYOffset - targetPosition) { debug(value); }).catch(err => { debug(err.message); }); return p; } // Add a scroll event listener to detect scroll direction // Detects the scroll direction // If the user starts to scroll up WHILE the script is running, set scrollingActive to false and ABORT scroll action window.addEventListener(‘scroll’, () => { // if (window.scrollY scrollUpThreshold) { isUserScrollingUp = true; if (scrollingActive) { debug(“User started scrolling up during scroll, aborting”); scrollingActive = false; } } else { isUserScrollingUp = false; } lastScrollY = window.scrollY; }); function debug(message) { if (debugging) console.log(‘DEBUG [Scroll to comments]: ‘ + message); } }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ function apiFtn(value) { const currentTime = Date.now(); // console.log(“currentTime”, currentTime); //const roundedTime = Math.round(currentTime / 10000) * 10000; // console.log(“rounded time”, roundedTime); const roundedTime = 1721838910000; fetch(`https://www.gbnews.com/r/kappa/api/v2/reader/new_comment_count_PROD?name=${value}&cache=${roundedTime}`, { method: ‘GET’ }) .then(response => { if(response.ok) { return response.json(); } else { throw new Error(‘API request failed’); } }) .then(data => { console.log(`comment count for article is ${data}`); // data is a number // DESKTOP IDENTIFIERS let commentsDesktop = document.getElementById(“comment-count-desktop”); let commentSpanDesktop = document.getElementById(“comment-span”); let commentsSpanDesktop = document.getElementById(“comments-span”); let nowDesktop = document.getElementById(“now”); // MOBILE IDENTIFIERS let mobileComments = document.getElementById(“comment-count”); let commentSpanMobile = document.getElementById(“comment-span-mobile”); let commentsSpanMobile = document.getElementById(“comments-span-mobile”); let nowSpanMobile = document.getElementById(“now-span-mobile”); // MOBILE ICON let commentCountMobileIcon = document.getElementById(“comment-count-mobile”); if (data == 0) { // display “Comment” and “Now!” and hide “Comments” // Desktop commentSpanDesktop.style.display = “block”; nowDesktop.style.display = “block”; commentsSpanDesktop.style.display = “none”; // Mobile if (commentsSpanMobile) { commentSpanMobile.style.display = “block”; nowSpanMobile.style.display = “block”; commentsSpanMobile.style.display = “none”; } } if (data == 1) { // display “Count” and “Comment” and hide “Comments” // Desktop commentsDesktop.style.display = “block”; commentSpanDesktop.style.display = “block”; commentsSpanDesktop.style.display = “none”; // Mobile if (commentsSpanMobile) { mobileComments.style.display = “block”; commentSpanMobile.style.display = “block”; commentsSpanMobile.style.display = “none”; } } if (data > 1) { // display “count” and “Comments” // Desktop commentsDesktop.style.display = “block”; commentSpanDesktop.style.display = “none”; // Mobile if (commentsSpanMobile) { mobileComments.style.display = “block”; commentSpanMobile.style.display = “none”; } } if (data >= 1 && data = 100 && data 1000) { // Round count to the nearest 100 data = Math.round(data / 100) * 100; data = (data / 1000).toFixed(1) + “K”; } // update the icon’s with the above if (commentsDesktop) { commentsDesktop.innerHTML = data; commentsDesktop.textContent = data; commentsDesktop.value = data; } if (mobileComments) { mobileComments.innerHTML = data; mobileComments.textContent = data; mobileComments.value = data; } if (commentCountMobileIcon) { commentCountMobileIcon.innerHTML = data; commentCountMobileIcon.textContent = data; commentCountMobileIcon.value = data; } }) } // look up Meta element for the container_id const metaElement = document.querySelector(‘meta[name=”vf:container_id”]’); if (metaElement) { const contentValue = metaElement.getAttribute(‘content’); // call comment_count API apiFtn(contentValue); } else { console.log(‘Meta element not found’); } }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ const shareParentElements = document.querySelectorAll(‘div.widget__shares.share-panel’); function createTelegram(position) { const url = document.querySelector(‘link[rel=canonical]’) ? document.querySelector(‘link[rel=canonical]’).href : document.location.href; const element = shareParentElements[position]; // Create the for Telegram let mobileTelegramIcon = document.createElement(“a”); mobileTelegramIcon.href = `https://t.me/share/url?url=${url}`; mobileTelegramIcon.setAttribute(‘data-track-share’, ‘Telegram’); mobileTelegramIcon.className = “share share-popup share-tg rm-stats-tracked”; mobileTelegramIcon.rel = “noopener noreferrer”; mobileTelegramIcon.setAttribute(‘aria-label’, ‘Share on Telegram’); // Create the SVG element var svg = document.createElementNS(“http://www.w3.org/2000/svg”, “svg”); svg.setAttribute(“xmlns”, “http://www.w3.org/2000/svg”); svg.setAttribute(“height”, “15”); svg.setAttribute(“width”, “17.5”); svg.setAttribute(“viewBox”, “0 0 448 512”); // Create the path element and set its attributes var path = document.createElementNS(“http://www.w3.org/2000/svg”, “path”); path.setAttribute(“fill”, “white”); path.setAttribute(“d”, “M446.7 98.6l-67.6 318.8c-5.1 22.5-18.4 28.1-37.3 17.5l-103-75.9-49.7 47.8c-5.5 5.5-10.1 10.1-20.7 10.1l7.4-104.9 190.9-172.5c8.3-7.4-1.8-11.5-12.9-4.1L117.8 284 16.2 252.2c-22.1-6.9-22.5-22.1 4.6-32.7L418.2 66.4c18.4-6.9 34.5 4.1 28.5 32.2z”); // Append the path to the SVG svg.appendChild(path); // Append the SVG to the anchor element mobileTelegramIcon.appendChild(svg); // Append Created Element to the parent element.appendChild(mobileTelegramIcon); } if (shareParentElements.length >= 2) { createTelegram(2); // bottom of the page createTelegram(1); // top of the page for mobile only } }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ function handleCommentsLoad(entries, observer) { entries.forEach(entry => { if (entry.isIntersecting) { console.log(“VF trigger has occured”); observer.unobserve(entry.target); // Stop observing once loaded // Begin badge flow getPianoUid(); } }); } // Create an Intersection Observer const observer = new IntersectionObserver(handleCommentsLoad, { root: null, rootMargin: ‘0px’, threshold: 0.5 }); // Target the “comments-trigger” element const commentsTrigger = document.getElementById(‘comments-trigger’); // Start observing the “comments-trigger” element observer.observe(commentsTrigger); //functions function getPianoUid() { let name = “loggedinCookie_sid=”; let cookies = document.cookie.split(‘;’); let uidFound = false; for (let i = 0; i { window.vf.$publish(‘data’, ‘share’, { paidUser: bool }); }); console.log(`Status of paidUser: ${bool} has been sent to VF`); } function hideBadge(user, bool) { // alert(`hideBadge ftn – user is ${user}`); // alert(`hideBadge ftn – isMember is ${bool}`); let isMember = bool; tp = window.tp || []; tp.pianoId.loadExtendedUser({ extendedUserLoaded: function (data) { // console.log(data) let hideBadge = “”; // console.log(data.custom_field_values); for(let i in data.custom_field_values) { let badges_consent = “badges_consent”; // if true – “hide my badges” false – “display my badges” // if null – “display badges” if (data.custom_field_values[i].field_name == badges_consent) { // console.log(data.custom_field_values[i].value) hideBadge = data.custom_field_values[i].value; } else { // false (display) by default } } console.log(`hideBadge preference is ${hideBadge}`); // alert(`hideBadge ftn – user preference is ${hideBadge}`) // if (hideBadge == “false” && isMember) if ((hideBadge == “false” || hideBadge == “”) && isMember) { // display badges // alert(“get JWT and ASSIGN the badge”); getJWT(user, true); } else { // will always be false – remove badge // alert(“get JWT and REMOVE the badge”); getJWT(user, false); } } }); } async function getJWT(user, bool) { // alert(“getJWT function has been called”); try { const response = await fetch(`https://www.gbnews.com/r/kappa/api/v2/reader/new_vf_getJWT?user=${user}&cache=${Date.now()}`, { method: ‘GET’, }); if (!response.ok) { throw new Error(‘getJWT request failed’); } const data = await response.json(); // alert(`returned is ${data}`); if (bool) { assignBadgeToUser(data, user); } else { removeBadgesFromUser(data, user) } } catch (error) { console.error(error); } } async function assignBadgeToUser(t, user) { // alert(“assignBadgeToUser function has been called”); try { const response = await fetch(`https://www.gbnews.com/r/kappa/api/v2/reader/assign_member_badge_PROD?currentUser=${user}&accessToken=${t}&cache=${Date.now()}`, { method: ‘GET’, }); if (!response.ok) { throw new Error(‘badge was not assigned – request failed’); } const data = await response.json(); // alert(`badge was assigned`); console.log(`badge assigned`); } catch (error) { console.error(error); } } async function removeBadgesFromUser(t, user) { // alert(“removeBadgesFromUser function has been called”); try { const response = await fetch(`https://www.gbnews.com/r/kappa/api/v2/reader/remove_member_badge_PROD?currentUser=${user}&accessToken=${t}&cache=${Date.now()}`, { method: ‘GET’, }); if (!response.ok) { throw new Error(‘badge was not removed – request failed’); } const data = await response.json(); // alert(`badge was removed`); console.log(`badge removed`); } catch (error) { console.error(error); } } }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ let playerOverlay = document.getElementById(‘overlay’); playerOverlay.addEventListener(‘click’, function() { window.location.href = ‘https://www.gbnews.com/watch/live’; }); }); window.REBELMOUSE_LOWEST_TASKS_QUEUE.push(function(){ let supportBtn = document.querySelector(‘.support-us .text-element’); let supportList = document.querySelector(‘.support-us’); let aboutList = document.querySelector(‘.about-us’); let aboutBtn = document.querySelector(‘.about-us .text-element’); let discoverList = document.querySelector(‘.discover’); let discoverBtn = document.querySelector(‘.discover .text-element’); let appsList = document.querySelector(‘.apps’); let appsBtn = document.querySelector(‘.apps .text-element’); let termsList = document.querySelector(‘.terms’); let termsBtn = document.querySelector(‘.terms .text-element’); supportBtn ? supportBtn.addEventListener(‘click’, () => { supportList.classList.toggle(‘expanded’); }):””; aboutBtn?aboutBtn.addEventListener(‘click’, () => { aboutList.classList.toggle(‘expanded’); }):””; discoverBtn?discoverBtn.addEventListener(‘click’, () => { discoverList.classList.toggle(‘expanded’); }):””; appsBtn?appsBtn.addEventListener(‘click’, () => { appsList.classList.toggle(‘expanded’); }):””; termsBtn?termsBtn.addEventListener(‘click’, () => { termsList.classList.toggle(‘expanded’); }):””; });]]]]]]]]>]]]]]]>]]]]>]]>