diff --git a/README.md b/README.md index 916e430..81cd2c9 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ サムネ使用時はエラーの種類に関わらず「スレ画像削除」のエラー画像が表示されます。 - 過剰なリクエストの抑制 サーバーへの過剰なリクエストを抑制しました。デメリットとしてポップアップまでの時間の最小値が300ミリ秒に制限されます。表示の遅れが気になるときはサムネ使用をご検討下さい。 - - ![\(New\)](images/new.png "New") [KOSHIAN リロード拡張 改](https://github.com/akoya-tomo/koshian_reload_futaba_kai/)のページ更新無しでのカタログリロードに対応 + - [KOSHIAN リロード拡張 改](https://github.com/akoya-tomo/koshian_reload_futaba_kai/)のページ更新無しでのカタログリロードに対応 ## インストール **GitHub** -[![インストールボタン](images/install_button.png "クリックでアドオンをインストール")](https://github.com/akoya-tomo/koshian_image_popuper_kai/releases/download/v1.6.2/koshian_image_popuper_kai-1.6.2-fx.xpi) +[![インストールボタン](images/install_button.png "クリックでアドオンをインストール")](https://github.com/akoya-tomo/koshian_image_popuper_kai/releases/download/v1.6.3/koshian_image_popuper_kai-1.6.3-fx.xpi) ※「接続エラーのため、アドオンをダウンロードできませんでした。」と表示されてインストール出来ない時は、インストールボタンを右クリックしてxpiファイルをダウンロードし、メニューのツール→アドオン(またはCtrl+Shift+A)で表示されたアドオンマネージャーのページにxpiファイルをドラッグ&ドロップして下さい。 @@ -54,6 +54,9 @@ * [futaba thread highlighter K](https://greasyfork.org/ja/scripts/36639-futaba-thread-highlighter-k/)がピックアップしたスレの画像もポップアップさせたい場合はfutaba thread highlighter K **rev13以上**をインストールして下さい。 ## 更新履歴 +* v1.6.3 2019-06-07 + - Firefox 68以降でポップアップが表示されたままになる不具合を修正 + - 一度開いたポップアップ画像・動画のurlをリロードしても記憶するように修正 * v1.6.2 2019-05-17 - KOSHIAN リロード拡張 改のページ更新無しでのカタログリロードに対応 * v1.6.1 2019-05-15 diff --git a/koshian_image_popuper/cat.js b/koshian_image_popuper/cat.js index 1e52559..fe61a12 100644 --- a/koshian_image_popuper/cat.js +++ b/koshian_image_popuper/cat.js @@ -190,10 +190,15 @@ class Cell{ this.setVideo(media_url); } + let ss_obj = {}; + ss_obj.media_url = media_url; + ss_obj.thre_text = thre_text; + sessionStorage[this.img_src] = JSON.stringify(ss_obj); + //this.loaded = true; } - onThreNotFound(e){ + onThreNotFound(e){ // eslint-disable-line no-unused-vars let media_url = browser.extension.getURL("img/ThreadNotFound.png"); //console.log("cat.js : media_url = " + media_url); this.setImage(media_url); @@ -205,11 +210,11 @@ class Cell{ this.setImage(media_url); //this.loading = false; this.img.error = true; - console.log("KOSHIAN_image_popuper/cat.js - onThreError(e):"); + console.error("KOSHIAN_image_popuper/cat.js/onThreError - " + e.name + ": " + e.message); console.dir(e); } - onThreTimeout(e){ + onThreTimeout(e){ // eslint-disable-line no-unused-vars let media_url = browser.extension.getURL("img/TimeOut.png"); this.setImage(media_url); this.img.error = true; @@ -224,18 +229,42 @@ class Cell{ this.setImage(media_url); } //this.loaded = true; + } else if (sessionStorage.getItem(this.img_src)) { + let ss_json = sessionStorage.getItem(this.img_src), ss_obj; + if (ss_json) { + ss_obj = JSON.parse(ss_json); + } else { + ss_obj = {}; + } + let media_url = ss_obj.media_url; + let thre_text = ss_obj.thre_text; + + if (!media_url) { + return; + } + + if(thre_text){ + this.text.textContent = this.res_num + thre_text; + } + + if(isImage(media_url)){ + this.setImage(media_url); + }else{ + this.setVideo(media_url); + } } else { let xhr = new XMLHttpRequest(); xhr.responseType = "document"; xhr.timeout = 60000; xhr.open('GET', this.link); - xhr.onload = (e) => {if(xhr.status == 200){ - this.onThreLoad(xhr.responseXML); - } - if(xhr.status == 404){ - this.onThreNotFound(e); - } - }; + xhr.onload = (e) => { + if(xhr.status == 200){ + this.onThreLoad(xhr.responseXML); + } + if(xhr.status == 404){ + this.onThreNotFound(e); + } + }; xhr.onerror = (e) => {this.onThreError(e);}; xhr.ontimeout = (e) => {this.onThreTimeout(e);}; xhr.send(); @@ -349,9 +378,7 @@ class Cell{ if(this.img && this.img.error){ this.img = null; - while(this.popup.firstChild){ - this.popup.removeChild(this.popup.firstChild); - } + this.popup.textContent = null; // 子要素全削除 this.loading = false; this.loaded = false; } @@ -483,7 +510,9 @@ function isCatalog(){ function setCellMap(target_list, name, index) { let hasClass = name.charAt(0) == "."; // nameの先頭が"."ならclassNameとして処理 - if(hasClass) name = name.substr(1); + if(hasClass) { + name = name.substr(1); + } for(let i = 0; i < target_list.length; ++i){ let target = target_list[i]; @@ -496,8 +525,15 @@ function setCellMap(target_list, name, index) { continue; } - let dummy = document.createElement("a"); - target.appendChild(dummy); + // 既存のポップアップコンテナがあれば削除 + let containers = target.getElementsByClassName("KOSHIAN_image_popup_container"); + for (let container of containers) { + container.remove(); + } + + let container = document.createElement("a"); + container.className = "KOSHIAN_image_popup_container"; + target.appendChild(container); let a = a_list[0]; let img = img_list[0]; @@ -511,14 +547,14 @@ function setCellMap(target_list, name, index) { font = "(" + font_list[0].textContent + ")"; } - cell_map.push(new Cell(a.href, dummy, img, img_src, comment, font, index)); + cell_map.push(new Cell(a.href, container, img, img_src, comment, font, index)); ++index; } return index; } -function onError(error){ +function onError(error){ // eslint-disable-line no-unused-vars } function safeGetValue(value, default_value){ @@ -609,14 +645,16 @@ function onLoad(){ } else { document.addEventListener("AkahukuContentApplied", () => { target = document.getElementById("akahuku_catalog_reload_status"); - if (target) checkAkahukuReload(); + if (target) { + checkAkahukuReload(); + } }); } function checkAkahukuReload() { let config = { childList: true }; let observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { + mutations.forEach(function(mutation) { // eslint-disable-line no-unused-vars if (target.textContent == status) return; status = target.textContent; if (status == "完了しました" || status == "アンドゥしました" || status == "リドゥしました") { diff --git a/koshian_image_popuper/manifest.json b/koshian_image_popuper/manifest.json index 249aff1..b2b5378 100644 --- a/koshian_image_popuper/manifest.json +++ b/koshian_image_popuper/manifest.json @@ -3,7 +3,7 @@ "name":"KOSHIAN カタログの画像をポップアップで表示 改", - "version":"1.6.2", + "version":"1.6.3", "description":"スレ画像をポップアップ表示します", diff --git a/updates.json b/updates.json index cec5ab7..913c05c 100644 --- a/updates.json +++ b/updates.json @@ -2,7 +2,7 @@ "addons": { "{4B803436-E2DF-11E7-8568-2E3D1843E317}": { "updates": [ - { "version": "1.6.2", "update_link": "https://github.com/akoya-tomo/koshian_image_popuper_kai/releases/download/v1.6.2/koshian_image_popuper_kai-1.6.2-fx.xpi" } + { "version": "1.6.3", "update_link": "https://github.com/akoya-tomo/koshian_image_popuper_kai/releases/download/v1.6.3/koshian_image_popuper_kai-1.6.3-fx.xpi" } ] } }