@@ -34,54 +34,3 @@ chrome.alarms.onAlarm.addListener(() => {
3434 const minute = date . getMinutes ( ) ;
3535 noticeAlert ( hour , minute ) ;
3636} ) ;
37-
38- function request_proxy ( { url, method, data } ) {
39- const XHR = new XMLHttpRequest ( ) ;
40- XHR . open ( method , url ) ;
41- XHR . setRequestHeader ( "Content-Type" , "application/json;charset=UTF-8" ) ;
42- XHR . send ( data ) ;
43- XHR . onreadystatechange = function ( ) {
44- if ( XHR . readyState === 4 ) {
45- console . log ( XHR . responseText ) ;
46- }
47- } ;
48- }
49-
50- const wbSpiderConfig = { } ;
51-
52- chrome . storage . onChanged . addListener ( ( changes , namespace ) => {
53- console . log ( "change ======" ) ;
54- for ( const [ key , { oldValue, newValue } ] of Object . entries ( changes ) ) {
55- console . log ( "change key" , key , newValue ) ;
56- if ( key === "wbSpider" || key === "wbSpiderStart" ) {
57- if ( key === "wbSpider" ) {
58- wbSpiderConfig . url = newValue ;
59- } else if ( key === "wbSpiderStart" ) {
60- wbSpiderConfig . start = newValue ;
61- }
62- }
63- console . log ( wbSpiderConfig ) ;
64- }
65- } ) ;
66-
67- chrome . runtime . onMessage . addListener ( ( data , sender , sendResponse ) => {
68- console . log ( data , wbSpiderConfig ) ;
69- if ( wbSpiderConfig . url !== "" && wbSpiderConfig . start ) {
70- fetch ( wbSpiderConfig . url , {
71- method : "POST" ,
72- body : JSON . stringify ( data ) ,
73- headers : {
74- "Content-Type" : "application/json;charset=UTF-8" ,
75- } ,
76- } )
77- . then ( ( resp ) => {
78- console . log ( resp ) ;
79- sendResponse ( { code : 200 } ) ;
80- } )
81- . catch ( ( err ) => {
82- console . log ( err ) ;
83- sendResponse ( { code : 500 } ) ;
84- } ) ;
85- }
86- sendResponse ( { code : 200 } ) ;
87- } ) ;
0 commit comments