This commit is contained in:
Javier Casares 2026-06-05 14:04:51 +00:00
commit f936aeb807
8 changed files with 15710 additions and 0 deletions

44
assets/css/profile.css Normal file
View file

@ -0,0 +1,44 @@
.robotstxt-2fa-method-list {
margin-top: 0.5em;
}
.robotstxt-2fa-method {
margin-bottom: 1.5em;
}
.robotstxt-2fa-method:last-of-type {
margin-bottom: 0;
}
.robotstxt-2fa-otp-qr {
height: auto;
max-width: 220px;
}
.robotstxt-2fa-recovery-code-grid {
display: grid;
gap: 8px 16px;
grid-template-columns: repeat(2, minmax(140px, 1fr));
}
.robotstxt-2fa-recovery-code-row {
display: contents;
}
.robotstxt-2fa-recovery-code-item {
font-size: 1.2em;
font-weight: 600;
}
.robotstxt-2fa-recovery-confirm {
margin-top: 1em;
}
.robotstxt-2fa-recovery-confirm label {
display: block;
margin-bottom: 0.5em;
}
.robotstxt-2fa-recovery-confirm input {
max-width: 200px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
assets/img/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
assets/img/icon-128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

BIN
assets/img/icon-256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
assets/img/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

111
assets/js/recovery-codes.js Normal file
View file

@ -0,0 +1,111 @@
( function() {
'use strict';
const settings = window.robotstxt2FARecovery || {};
document.addEventListener( 'DOMContentLoaded', () => {
const root = document;
bindCopyButtons( root );
} );
function bindCopyButtons( scope ) {
const buttons = scope.querySelectorAll( '[data-robotstxt-2fa-copy-button]' );
buttons.forEach( ( button ) => {
if ( '1' === button.dataset.robotstxt2FaCopyBound ) {
return;
}
button.dataset.robotstxt2FaCopyBound = '1';
button.addEventListener( 'click', () => {
const container = button.closest( '[data-robotstxt-2fa-codes-scope]' );
if ( ! container ) {
return;
}
const codes = Array.from( container.querySelectorAll( '[data-robotstxt-2fa-code]' ) )
.map( ( element ) => element.textContent || '' )
.filter( ( value ) => value.trim().length > 0 );
if ( ! codes.length ) {
return;
}
copyCodes( codes.join( '\n' ), container );
} );
} );
}
function copyCodes( text, scope ) {
const feedback = scope.querySelector( '[data-robotstxt-2fa-copy-feedback]' );
const confirmMessage = getString( 'copyConfirm' );
const fallbackMessage = getString( 'copyFallback' );
const updateFeedback = ( message, isError ) => {
if ( ! feedback || ! message ) {
return;
}
feedback.hidden = false;
feedback.textContent = message;
if ( isError ) {
feedback.classList.add( 'error' );
} else {
feedback.classList.remove( 'error' );
}
};
if ( navigator.clipboard && navigator.clipboard.writeText ) {
navigator.clipboard.writeText( text )
.then( () => {
if ( confirmMessage ) {
updateFeedback( confirmMessage, false );
}
} )
.catch( () => {
if ( fallbackMessage ) {
updateFeedback( fallbackMessage, true );
}
} );
return;
}
const helper = document.createElement( 'textarea' );
helper.value = text;
helper.setAttribute( 'readonly', 'readonly' );
helper.style.position = 'absolute';
helper.style.left = '-9999px';
document.body.appendChild( helper );
helper.select();
try {
const success = document.execCommand( 'copy' );
if ( success && confirmMessage ) {
updateFeedback( confirmMessage, false );
return;
}
} catch ( error ) {
// Continue to fallback message below when execCommand fails.
} finally {
document.body.removeChild( helper );
}
if ( fallbackMessage ) {
updateFeedback( fallbackMessage, true );
}
}
function getString( key ) {
if ( settings.strings && settings.strings[ key ] ) {
return String( settings.strings[ key ] );
}
return '';
}
}() );