From 24cec85880600d3ff7c28f4fbf596b6fb3827bd1 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 4 Mar 2024 13:27:55 +0800 Subject: [PATCH 1/2] Allow web extension to get the content text direction and save --- pkg/extension/src/scripts/content/prepare-content.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/extension/src/scripts/content/prepare-content.js b/pkg/extension/src/scripts/content/prepare-content.js index 01dc089fa..5a5336267 100644 --- a/pkg/extension/src/scripts/content/prepare-content.js +++ b/pkg/extension/src/scripts/content/prepare-content.js @@ -134,6 +134,7 @@ contentCopyEl.style.left = '-2000px' contentCopyEl.style.zIndex = '-2000' contentCopyEl.innerHTML = document.body.innerHTML + const dir = document.dir // Appending copy of the content to the DOM to enable computed styles capturing ability // Without adding that copy to the DOM the `window.getComputedStyle` method will always return undefined. @@ -149,7 +150,7 @@ * capture them separately and concatenate them here with head and body tags * preserved. */ - const contentCopyHtml = `${document.head.innerHTML}${contentCopyEl.innerHTML}` + const contentCopyHtml = `${document.head.innerHTML}${contentCopyEl.innerHTML}` // Cleaning up the copy element contentCopyEl.remove() return contentCopyHtml From 7cd69da8b8634923660633f555f3074e4d5222ed Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 4 Mar 2024 13:33:06 +0800 Subject: [PATCH 2/2] Do not set dir if not rtl --- pkg/extension/src/scripts/content/prepare-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/extension/src/scripts/content/prepare-content.js b/pkg/extension/src/scripts/content/prepare-content.js index 5a5336267..03380601a 100644 --- a/pkg/extension/src/scripts/content/prepare-content.js +++ b/pkg/extension/src/scripts/content/prepare-content.js @@ -150,7 +150,7 @@ * capture them separately and concatenate them here with head and body tags * preserved. */ - const contentCopyHtml = `${document.head.innerHTML}${contentCopyEl.innerHTML}` + const contentCopyHtml = `${document.head.innerHTML}${contentCopyEl.innerHTML}` // Cleaning up the copy element contentCopyEl.remove() return contentCopyHtml