1// Copyright 2024 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5const button_selector = 'button[id=onetrust-accept-btn-handler]' 6const headline_text_id = 'maincontent' 7 8const button_observer = new MutationObserver(mutations => { 9 const button = document.querySelector(button_selector) 10 if (!button) { 11 return 12 } 13 // This script can run multiple times. 14 if (localStorage.getItem('already_run') === 'already_run') { 15 return 16 } 17 localStorage.setItem('already_run', 'already_run') 18 performance.mark('cookie_banner_shown') 19 button.click() 20}) 21 22button_observer.observe(document, {childList: true, subtree: true}); 23 24const headline_observer = new MutationObserver(mutations => { 25 performance.mark('update'); 26 const headline = document.getElementById(headline_text_id) 27 if (!headline) { 28 return 29 } 30 performance.mark('maincontent.created'); 31}); 32 33 34if (window.location == 35 'https://edition.cnn.com/2024/04/21/china/china-spy-agency-public-profile-intl-hnk/index.html') { 36 headline_observer.observe(document, {childList: true, subtree: true}); 37} 38