11/* eslint-env browser */
2- /* eslint builtins */
3-
4- if ( ~ window . name . indexOf ( 'h_gtn_' ) ) { //this is an incoming phone call notifcation
5- webkit . messageHandlers . unhideApp . postMessage ( [ ] ) ; //get the app in the user's face right now!!
6- window . addEventListener ( 'DOMSubtreeModified' , function ( e ) {
7- if ( btn = document . querySelector ( 'button + button' ) ) { //answer button
8- document . removeEventListener ( 'DOMSubtreeModified' , this , false ) ;
9- btn . autofocus = true //hafta apply this before .onload
10- }
11- } ) ;
12- window . addEventListener ( "keypress" , function ( e ) {
13- switch ( e . which ) {
14- case 13 : //Enter
15- case 32 : //Space
16- document . querySelector ( 'button + button' ) . click ( ) ; //Answer call
17- break ;
18- case 27 : //Esc
19- case 9 : //Tab
20- case 8 : //Bksp
21- document . querySelector ( 'button' ) . click ( ) ; //Decline call
22- break ;
23- default :
24- }
25- } ) ;
26- } ;
2+ /*eslint eqeqeq:0, quotes:0, space-infix-ops:0, curly:0*/
273
284if ( window == top )
295( function ( ) { //IIFE
@@ -49,7 +25,7 @@ if (window == top)
4925
5026 var css = document . createElement ( "style" ) ;
5127 css . type = 'text/css' ;
52- css . id = 'unSocialSpam'
28+ css . id = 'unSocialSpam' ;
5329 css . innerHTML = "\
5430 body, #content { overflow: hidden; background-color: transparent !important; }\
5531 #contentPane, #gb, #gba, #notify-widget-pane { display: none; }\
@@ -90,14 +66,41 @@ if (window.name == 'preld') { //frame-id ^gtn_ this is a chatbox iframe
9066 css . type = 'text/css' ;
9167 css . id = 'appleEmoji'
9268 css . innerHTML = "\
93- span[data-emo] span { opacity: 1.0 !important; width: auto !important; } \
69+ span[data-emo] span { opacity: 1.0 !important; width: auto !important; font-size: 12pt; } \
9470 span[data-emo] div { display: none !important; } \
9571 \
9672 " ;
9773 document . head . appendChild ( css ) ;
9874 }
9975 }
10076 document . addEventListener ( 'DOMSubtreeModified' , injectCSS , false ) ; //mutation events are deprecated
77+
78+ document . addEventListener ( 'DOMSubtreeModified' , function ( e ) {
79+ // enable keyboard to quickly take/reject phone calls
80+ if ( btn = document . querySelector ( 'button[title="Answer call"]' ) ) { //answer button
81+ var from = document . QuerySelector ( 'div[googlevoice]' ) . innerText ;
82+ console . log ( Date ( ) + " [Incoming phone call from:] " + from ) ;
83+ document . removeEventListener ( 'DOMSubtreeModified' , this , false ) ;
84+ btn . autofocus = true //hafta apply this before .onload
85+ window . addEventListener ( "keypress" , function ( e ) {
86+ switch ( e . which ) {
87+ case 13 : //Enter
88+ case 32 : //Space
89+ document . querySelector ( 'button[title="Answer call"]' ) . click ( ) ;
90+ document . removeEventListener ( 'keypress' , this , false ) ;
91+ break ;
92+ case 27 : //Esc
93+ case 9 : //Tab
94+ case 8 : //Bksp
95+ document . querySelector ( 'button[title="Decline call"]' ) . click ( ) ;
96+ document . removeEventListener ( 'keypress' , this , false ) ;
97+ break ;
98+ default :
99+ }
100+ } ) ;
101+ webkit . messageHandlers . unhideApp . postMessage ( [ ] ) ; //get the app in the user's face right now!!
102+ }
103+ } ) ;
101104 } ) ( ) ;
102105
103106 // watch for pop-out button to appear
0 commit comments