Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- const links = Array.from( document.querySelectorAll( 'link[title]' ) );
- const styles = Array.from( new Set( links.map( link => link.title ) ) );
- const select = document.createElement( 'select' );
- if ( styles.length > 1 ) {
- select.setAttribute( 'style', 'position: absolute; top: 1em; right: 1em;' );
- for ( let i = 0; i < styles.length; i++ ) {
- const option = document.createElement( 'option' );
- option.text = 'CSS: ' + styles[ i ];
- option.value = styles[ i ];
- select.add( option );
- }
- document.body.appendChild( select );
- select.addEventListener( 'change', function( event ) {
- const title = event.target.options[ event.target.selectedIndex ].value;
- links.forEach( function( link ){
- link.disabled = true;
- if ( link.title === title ) {
- link.disabled = false;
- }
- });
- });
- }
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement