schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: code style improvements

willow 73c7c859 bd13a9fb

+20 -17
+20 -17
src/utils/index.ts
··· 135 135 return; 136 136 } 137 137 138 - if (snippet.toggle === true) { 139 - // check not already injected 140 - const style = document.querySelector(`userSnippet-${id}`); 141 - if (style) { 142 - logger.info(`user snippet with id ${id} already injected, aborting`); 143 - return; 144 - } 138 + if (!snippet.toggle) { 139 + logger.error(`trying to inject user snippet with id ${id} which is disabled, aborting`); 140 + return; 141 + } 145 142 146 - // inject user snippet 147 - fetch(`https://gist.githubusercontent.com/${snippet.author}/${id}/raw`) 148 - .then((response) => response.text()) 149 - .then((css) => { 150 - const style = document.createElement("style"); 151 - style.textContent = css; 152 - style.dataset.schooltape = `userSnippet-${id}`; 153 - document.head.appendChild(style); 154 - logger.info(`injected user snippet with id ${id}`); 155 - }); 143 + // check not already injected 144 + const style = document.querySelector(`userSnippet-${id}`); 145 + if (style) { 146 + logger.info(`user snippet with id ${id} already injected, aborting`); 147 + return; 156 148 } 149 + 150 + // inject user snippet 151 + fetch(`https://gist.githubusercontent.com/${snippet.author}/${id}/raw`) 152 + .then((response) => response.text()) 153 + .then((css) => { 154 + const style = document.createElement("style"); 155 + style.textContent = css; 156 + style.dataset.schooltape = `userSnippet-${id}`; 157 + document.head.appendChild(style); 158 + logger.info(`injected user snippet with id ${id}`); 159 + }); 157 160 } 158 161 159 162 export function uninjectUserSnippet(id: string) {