diff --git a/README.md b/README.md index 17db17e..cc86292 100644 --- a/README.md +++ b/README.md @@ -113,15 +113,15 @@ 火狐插件: -1. [易笺正常版 (v1.4.9)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian/) +1. [易笺正常版 (v1.4.9.1)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian/) -2. [易笺无界面版 (v1.2.8)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian_nogui/) +2. [易笺无界面版 (v1.2.8.1)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian_nogui/) Chrome插件: -1. [易笺正常版 (v1.4.9)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0) +1. [易笺正常版 (v1.4.9.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0) -2. [易笺无界面版 (v1.2.8)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0) +2. [易笺无界面版 (v1.2.8.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0) --- diff --git a/README_EN.md b/README_EN.md index edd6d47..381590c 100644 --- a/README_EN.md +++ b/README_EN.md @@ -115,15 +115,15 @@ Support for customized settings such as font size, line height, theme colors and Firefox: -1. [Regular (v1.4.9)](https://addons.mozilla.org/en-US/firefox/addon/yijian/) +1. [Regular (v1.4.9.1)](https://addons.mozilla.org/en-US/firefox/addon/yijian/) -2. [No-UI (v1.2.8)](https://addons.mozilla.org/en-US/firefox/addon/yijian_nogui/) +2. [No-UI (v1.2.8.1)](https://addons.mozilla.org/en-US/firefox/addon/yijian_nogui/) Chrome: -1. [Regular (v1.4.9)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0) +1. [Regular (v1.4.9.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0) -2. [No-UI (v1.2.8)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0) +2. [No-UI (v1.2.8.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0) --- diff --git a/manifests/Chrome/regular/manifest.json b/manifests/Chrome/regular/manifest.json index e1acf03..eb86e52 100644 --- a/manifests/Chrome/regular/manifest.json +++ b/manifests/Chrome/regular/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "易笺", "description": "txt(小说)阅读器:支持秒开本地的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。", - "version": "1.4.9", + "version": "1.4.9.1", "background": { "service_worker": "scripts_extension/Chrome/regular/activate.js" }, diff --git a/manifests/Firefox/regular/manifest.json b/manifests/Firefox/regular/manifest.json index 5f8ab2c..1ec4ae3 100644 --- a/manifests/Firefox/regular/manifest.json +++ b/manifests/Firefox/regular/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "易笺", "description": "txt(小说)阅读器:支持秒开本地的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。", - "version": "1.4.9", + "version": "1.4.9.1", "background": { "scripts": [ "scripts_extension/Firefox/regular/activate.js" diff --git a/scripts/ui_helpers.js b/scripts/ui_helpers.js index 07008fc..e21b545 100644 --- a/scripts/ui_helpers.js +++ b/scripts/ui_helpers.js @@ -25,13 +25,17 @@ function setMainContentUI() { }, 1000); // UI calculations - // var maxWidth = sh(100)/9*16; - const maxWidth = sh(100)*2; + const maxWidth = sh(100) / 9 * 16; + // const maxWidth = sh(100) * 2; style.ui_maxWidth = `${maxWidth}px`; + // windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin; style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString(); // console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft); - style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString(); + + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; @@ -54,6 +58,8 @@ function setMainContentUI() { tocContainer.style.marginRight = '0px'; tocContainer.style.marginBottom = '0px'; tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } // Pagination @@ -69,15 +75,30 @@ function setMainContentUI() { progressContainer.style.marginBottom = '2.5em'; progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; progressContainer.style.top = '75%'; + + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } } function updateTOCUI(isIncreasing) { + const maxWidth = parseFloat(style.ui_maxWidth); + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); + if (isVariableDefined(tocContainer)) { + tocContainer.style.width = style.ui_tocWidth + '%'; tocContainer.style.height = style.ui_tocHeight + '%'; if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) { tocContainer.style.height = '50%'; } + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; + } + + if (isVariableDefined(progressContainer)) { + progressContainer.style.width = style.ui_tocWidth + '%'; + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } if (isVariableDefined(paginationContainer)) { @@ -95,7 +116,6 @@ function updateTOCUI(isIncreasing) { } } - const maxWidth = parseFloat(style.ui_maxWidth); const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; style.ui_paginationCenter = paginationLeft.toString(); diff --git a/scripts_extension/Chrome/no-ui/manifest.json b/scripts_extension/Chrome/no-ui/manifest.json index 26f9c6d..ac896b8 100755 --- a/scripts_extension/Chrome/no-ui/manifest.json +++ b/scripts_extension/Chrome/no-ui/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "易笺(无界面版)", "description": "txt(小说)阅读器:支持本地和云端的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。", - "version": "1.2.8", + "version": "1.2.8.1", "permissions": [], "content_scripts": [ { diff --git a/scripts_extension/Chrome/no-ui/scripts/ui_helpers.js b/scripts_extension/Chrome/no-ui/scripts/ui_helpers.js index d87adab..2324836 100644 --- a/scripts_extension/Chrome/no-ui/scripts/ui_helpers.js +++ b/scripts_extension/Chrome/no-ui/scripts/ui_helpers.js @@ -18,14 +18,18 @@ function setMainContentUI() { } // UI calculations - // var maxWidth = sh(100)/9*16; - const maxWidth = sh(100)*2; + const maxWidth = sh(100) / 9 * 16; + // const maxWidth = sh(100) * 2; style.ui_maxWidth = `${maxWidth}px`; + // windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin; style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString(); // console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft); - style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString(); - + + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); + const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; style.ui_paginationCenter = paginationLeft.toString(); @@ -47,6 +51,8 @@ function setMainContentUI() { tocContainer.style.marginRight = '0px'; tocContainer.style.marginBottom = '0px'; tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } // Pagination @@ -62,15 +68,30 @@ function setMainContentUI() { progressContainer.style.marginBottom = '2.5em'; progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; progressContainer.style.top = '75%'; + + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } } function updateTOCUI(isIncreasing) { + const maxWidth = parseFloat(style.ui_maxWidth); + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); + if (isVariableDefined(tocContainer)) { + tocContainer.style.width = style.ui_tocWidth + '%'; tocContainer.style.height = style.ui_tocHeight + '%'; if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) { tocContainer.style.height = '50%'; } + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; + } + + if (isVariableDefined(progressContainer)) { + progressContainer.style.width = style.ui_tocWidth + '%'; + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } if (isVariableDefined(paginationContainer)) { @@ -88,7 +109,6 @@ function updateTOCUI(isIncreasing) { } } - const maxWidth = parseFloat(style.ui_maxWidth); const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; style.ui_paginationCenter = paginationLeft.toString(); diff --git a/scripts_extension/Firefox/no-ui/manifest.json b/scripts_extension/Firefox/no-ui/manifest.json index 1eb4c40..1ec47ea 100755 --- a/scripts_extension/Firefox/no-ui/manifest.json +++ b/scripts_extension/Firefox/no-ui/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "易笺(无界面版)", "description": "txt(小说)阅读器:支持本地和云端的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。", - "version": "1.2.8", + "version": "1.2.8.1", "permissions": [], "content_scripts": [ { diff --git a/scripts_extension/Firefox/no-ui/scripts/ui_helpers.js b/scripts_extension/Firefox/no-ui/scripts/ui_helpers.js index d87adab..2324836 100644 --- a/scripts_extension/Firefox/no-ui/scripts/ui_helpers.js +++ b/scripts_extension/Firefox/no-ui/scripts/ui_helpers.js @@ -18,14 +18,18 @@ function setMainContentUI() { } // UI calculations - // var maxWidth = sh(100)/9*16; - const maxWidth = sh(100)*2; + const maxWidth = sh(100) / 9 * 16; + // const maxWidth = sh(100) * 2; style.ui_maxWidth = `${maxWidth}px`; + // windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin; style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString(); // console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft); - style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString(); - + + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); + const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; style.ui_paginationCenter = paginationLeft.toString(); @@ -47,6 +51,8 @@ function setMainContentUI() { tocContainer.style.marginRight = '0px'; tocContainer.style.marginBottom = '0px'; tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } // Pagination @@ -62,15 +68,30 @@ function setMainContentUI() { progressContainer.style.marginBottom = '2.5em'; progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%'; progressContainer.style.top = '75%'; + + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } } function updateTOCUI(isIncreasing) { + const maxWidth = parseFloat(style.ui_maxWidth); + const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth); + const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100); + style.ui_tocWidth = tocWidth.toString(); + if (isVariableDefined(tocContainer)) { + tocContainer.style.width = style.ui_tocWidth + '%'; tocContainer.style.height = style.ui_tocHeight + '%'; if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) { tocContainer.style.height = '50%'; } + + tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; + } + + if (isVariableDefined(progressContainer)) { + progressContainer.style.width = style.ui_tocWidth + '%'; + progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`; } if (isVariableDefined(paginationContainer)) { @@ -88,7 +109,6 @@ function updateTOCUI(isIncreasing) { } } - const maxWidth = parseFloat(style.ui_maxWidth); const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft); const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100; style.ui_paginationCenter = paginationLeft.toString();