@@ -13,10 +13,9 @@ async function getCurrentSelectionData() {
13
13
target : { tabId : currentTab . id } ,
14
14
func : async ( ) => {
15
15
let selectionText = await chrome . storage . local . get ( [ "snip_content" , "snip_type" ] ) ;
16
- disableListener = true ; // Temporarily disable
17
- await chrome . storage . local . remove ( [ "snip_content" , "snip_type" ] ) ;
18
- disableListener = false ; // Re-enable
16
+
19
17
if ( ! window . location . href . endsWith ( ".pdf" ) && selectionText . snip_content === undefined ) {
18
+ console . log ( window . getSelection ( ) . toString ( ) )
20
19
return {
21
20
snip_content : window . getSelection ( ) . toString ( ) ,
22
21
snip_type : "text" ,
@@ -38,6 +37,7 @@ async function getCurrentSelectionData() {
38
37
39
38
function App ( ) {
40
39
const [ snipd , setSnipd ] = useState ( ) ;
40
+ chrome . runtime . connect ( { name : 'mySidepanel' } ) ;
41
41
42
42
useEffect ( ( ) => {
43
43
const updateSnipdFromSelection = ( ) => {
@@ -49,17 +49,6 @@ function App() {
49
49
50
50
updateSnipdFromSelection ( ) ;
51
51
52
- // const listener = (changes, namespace) => {
53
- // if (namespace === 'local') {
54
- // updateSnipdFromSelection();
55
- // }
56
- // };
57
-
58
- // const listener = (changes, namespace) => {
59
- // if (namespace === "local" && (changes.snip_content || changes.snip_type)) {
60
- // updateSnipdFromSelection();
61
- // }
62
- // };
63
52
64
53
const listener = ( changes , namespace ) => {
65
54
if ( namespace === 'local' && ! disableListener ) {
0 commit comments