We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c65fd0 commit f04b35cCopy full SHA for f04b35c
index.js
@@ -1,7 +1,12 @@
1
'use strict';
2
/**
3
- * @return {string} plain-text title from current page.
+ * @return {string} selected text or plain-text title from current page.
4
**/
5
module.exports = function () {
6
- return window.document.title;
+ var selected = ('getSelection' in window ? window : document).getSelection().toString();
7
+ var title = window.document.title;
8
+ if (selected) {
9
+ return selected;
10
+ }
11
+ return title;
12
};
readme.md
@@ -29,7 +29,7 @@ browserTitleOrSelection();
29
30
### browserTitleOrSelection() -> String
31
32
-*Title*
+*Selected text* OR *Title*
33
34
35
## Changelog
0 commit comments