diff --git a/radioUpdater/assets/js/articles.js b/radioUpdater/assets/js/articles.js index 00ffdae..b59e5f0 100644 --- a/radioUpdater/assets/js/articles.js +++ b/radioUpdater/assets/js/articles.js @@ -2,11 +2,15 @@ const updateArticleView = function (articleName) { let actions = addIdByQuery('div.doi-actions', 'article-actions') - let button = document.createElement('a') - button.classList.add('btn') - button.classList.add('btn-flat') - button.style.marginRight = '2px' - button.innerText = 'Q' - button.href = '/questions/new/?article=' + articleName - actions.prepend(button) + if (actions) { + let button = document.createElement('a') + button.classList.add('btn') + button.classList.add('btn-flat') + button.style.marginRight = '2px' + button.innerText = 'Q' + button.href = '/questions/new/?article=' + articleName + + actions.prepend(button) + } + } \ No newline at end of file diff --git a/radioUpdater/assets/js/contentScript.js b/radioUpdater/assets/js/contentScript.js index 998c032..1fde258 100644 --- a/radioUpdater/assets/js/contentScript.js +++ b/radioUpdater/assets/js/contentScript.js @@ -1,12 +1,12 @@ const pathname = window.location.pathname const articleType = pathname.split('/')[1] -const finalPart = pathname.split('/')[2] +const finalPart = pathname.split('/').pop() const isEdit = finalPart === 'edit' || finalPart === 'new' -if (articleType === 'articles') { - updateArticleView(finalPart) -} else if (articleType === 'articles' && isEdit) { +if (articleType === 'articles' && isEdit) { updateArticleEdit() +} else if (articleType === 'articles') { + updateArticleView(finalPart) } else if (articleType === 'cases' && isEdit) { updateCaseEdit() } else if (articleType === 'questions' && isEdit) { diff --git a/radioUpdater/assets/js/questions.js b/radioUpdater/assets/js/questions.js index 372c5df..0c1736d 100644 --- a/radioUpdater/assets/js/questions.js +++ b/radioUpdater/assets/js/questions.js @@ -72,7 +72,7 @@ function watchForArticleUpdates() if (relatedArticleList) { let observer = new MutationObserver( function() { document.getElementById('auto-question-button').disabled = relatedArticleList.childElementCount < 1 - document.getElementById('preselected-article-warning').style.display = relatedArticleList.childElementCount < 1 ? 'block' : 'none' +// document.getElementById('preselected-article-warning').style.display = relatedArticleList.childElementCount < 1 ? 'block' : 'none' }) observer.observe(relatedArticleList, { attributes: true, childList: true, attributeOldValue: true }) @@ -109,6 +109,7 @@ function getNewQuestion() { let article = null; if (relatedArticles) { + article = relatedArticles.getElementsByTagName('a')[0].getAttribute("href") article = relatedArticles.getElementsByTagName('a')[0].getAttribute("href").substring(article.lastIndexOf('/') + 1) } else if (articleName) { article = articleName diff --git a/radioUpdater/manifest.json b/radioUpdater/manifest.json index e1d39db..8e836f8 100644 --- a/radioUpdater/manifest.json +++ b/radioUpdater/manifest.json @@ -1,6 +1,6 @@ { "name": "RadioUpdater", - "version": "2.1", + "version": "2.4", "description": "Replace references on Radiopaedia.", "manifest_version": 3, "content_scripts": [