diff --git a/js/contentScript/pubpeer.js b/js/contentScript/pubpeer.js index 62c590f..f4b326d 100644 --- a/js/contentScript/pubpeer.js +++ b/js/contentScript/pubpeer.js @@ -13,6 +13,7 @@ class PubPeer { this.type = ""; this.publicationIds = []; this.publications = []; + this.pubpeerUrls = []; this.uriEncodedUrls = {}; this.pageUrls = this.extractValidUrls(); this.uriEncodedDOIs = {}; @@ -145,7 +146,7 @@ class PubPeer { }; let param = { - version: "1.6.0", + version: "1.6.2", browser: Browser.name, urls: this.pageUrls, }; @@ -205,6 +206,20 @@ class PubPeer { break; } this.initTopBarRemoveEvent(); + this.initHeaderSubContentToggleEvent(); + } + + initHeaderSubContentToggleEvent() { + const toggleElement = document.getElementById("pubpeer-toggle-subcontent"); + if (toggleElement) { + toggleElement.onclick = function () { + const subContent = document.getElementById("pubpeer-header-subcontent"); + if (subContent) { + subContent.style.display = + subContent.style.display === "none" ? "block" : "none"; + } + }; + } } initTopBarRemoveEvent() { @@ -212,9 +227,10 @@ class PubPeer { "btn-close-pubpeer-article-summary" ); if (closeElement) { + const that = this; closeElement.onclick = function () { - this.parentNode.remove(); - this.onAfterRemovingTopBar(); + this.parentNode.parentNode.remove(); + that.onAfterRemovingTopBar(); }; } } @@ -352,9 +368,38 @@ class PubPeer { `; } pElement.innerHTML = ` - - ${hrefText} -
×
+
1 + ? 'id="pubpeer-toggle-subcontent" style="cursor: pointer"' + : "" + }> + + ${hrefText} +
×
+
+ ${ + this.publications.length > 1 + ? `` + : "" + } `; document.body.prepend(pElement); this.onAfterAddingTopBar(); @@ -431,11 +476,14 @@ class PubPeer { if (publication.title) { if (!this.publicationIds.includes(publication.id)) { this.publicationIds.push(publication.id); - this.publications.push(publication); } } } } - this.validPublicationCount++; + if (!this.pubpeerUrls.includes(publication.url)) { + this.publications.push(publication); + this.pubpeerUrls.push(publication.url); + this.validPublicationCount++; + } } } diff --git a/manifest.json b/manifest.json index 5becf8a..322ef2d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "PubPeer", "description": "Show links to existing PubPeer comments", - "version": "1.6.1", + "version": "1.6.2", "manifest_version": 2, "author": "Pubpeer Foundation", "browser_action": {