1/** 2 * Adds a sparkle (â¨) button after the "Remember Me" checkbox on the login screen to open a popover with information 3 * about the bfcache opt-in. 4 * 5 * This is a JavaScript module, so the global namespace is not polluted. 6 * 7 * @since 1.1.0 8 */ 9 10/** 11 * Script module ID. 12 * 13 * @since 1.1.0 14 * @type {string} 15 */ 16const moduleId = '@nocache-bfcache/bfcache-opt-in'; 17 18/** 19 * JSON script containing the PHP exports. 20 * 21 * @since 1.0.0 22 * @type {HTMLScriptElement} 23 */ 24const jsonScript = /** @type {HTMLScriptElement} */ ( 25 document.getElementById( `wp-script-module-data-${ moduleId }` ) 26); 27 28/** 29 * Exports from PHP. 30 * 31 * @since 1.1.0 32 * @type {{ 33 * buttonTemplateId: string, 34 * }} 35 */ 36const data = JSON.parse( jsonScript.text ); 37 38// Add a button that opens a popover with information about the instant navigation feature. 39const p = document.querySelector( 40 'p.forgetmenot:has(> input#rememberme ):has(> label:last-child[for="rememberme"] )' 41); 42if ( p ) { 43 const tmpl = /** @type {HTMLTemplateElement} */ ( 44 document.getElementById( data.buttonTemplateId ) 45 ); 46 const button = /** @type {HTMLButtonElement} */ ( 47 tmpl.content.firstElementChild 48 ); 49 p.append( button ); 50}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.