Просмотр исходного кода

Display a different badge color when dev version found.

Mr.doob 9 месяцев назад
Родитель
Сommit
db366f2727
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      devtools/background.js

+ 5 - 3
devtools/background.js

@@ -59,11 +59,13 @@ chrome.runtime.onMessage.addListener( ( message, sender, sendResponse ) => {
 		// If three.js is detected, show a badge
 		if ( message.name === 'register' && message.detail && message.detail.revision ) {
 
-			const revision = String( parseInt( message.detail.revision, 10 ) );
+			const revision = String( message.detail.revision );
+			const number = revision.replace( /\D+$/, '' );
+			const isDev = revision.includes( 'dev' );
 
-			chrome.action.setBadgeText( { tabId: tabId, text: revision } ).catch( () => { /* Tab might be gone */ } );
+			chrome.action.setBadgeText( { tabId: tabId, text: number } ).catch( () => { /* Tab might be gone */ } );
 			chrome.action.setBadgeTextColor( { tabId: tabId, color: '#ffffff' } ).catch( () => { /* Tab might be gone */ } );
-			chrome.action.setBadgeBackgroundColor( { tabId: tabId, color: '#049ef4' } ).catch( () => { /* Tab might be gone */ } );
+			chrome.action.setBadgeBackgroundColor( { tabId: tabId, color: isDev ? '#ff0098' : '#049ef4' } ).catch( () => { /* Tab might be gone */ } );
 
 		}
 

粤ICP备19079148号