diff options
| -rw-r--r-- | js/App.js | 21 | ||||
| -rw-r--r-- | js/CommonFilters.js | 2 | ||||
| -rwxr-xr-x | js/common.js | 4 |
3 files changed, 4 insertions, 23 deletions
@@ -441,26 +441,9 @@ const App = { } }); }, - // http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac getSelectedText: function() { - let text = ""; - - if (typeof window.getSelection != "undefined") { - const sel = window.getSelection(); - if (sel.rangeCount) { - const container = document.createElement("div"); - for (let i = 0, len = sel.rangeCount; i < len; ++i) { - container.appendChild(sel.getRangeAt(i).cloneContents()); - } - text = container.innerHTML; - } - } else if (typeof document.selection != "undefined") { - if (document.selection.type == "Text") { - text = document.selection.createRange().textText; - } - } - - return text.stripTags(); + const sel = window.getSelection(); + return sel ? sel.toString().trim() : ""; }, displayIfChecked: function(checkbox, elemId) { if (checkbox.checked) { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index f6cc5a4e7..6d40373d6 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -527,6 +527,8 @@ const Filters = { `); if (!App.isPrefs()) { + // TODO: This section isn't working as expected (under Firefox 143, at least). + // `selectedText` is always empty at this point (tested by selecting some article text). const selectedText = App.getSelectedText(); if (selectedText != "") { diff --git a/js/common.js b/js/common.js index 9635ab492..99cf52fa1 100755 --- a/js/common.js +++ b/js/common.js @@ -167,10 +167,6 @@ Array.prototype.uniq = function() { return this.filter((v, i, a) => a.indexOf(v) === i); }; -String.prototype.stripTags = function() { - return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?(\/)?>|<\/\w+>/gi, ''); -} - /* exported xhr */ const xhr = { _ts: 0, |