@@ -35,6 +35,16 @@ chrome.contentSettings.plugins.clear({});
3535// For privacy reasons, ensure all exceptions are removed from settings.
3636chrome . contentSettings . javascript . clear ( { } ) ;
3737
38+ // rhill 2013-12-05: now we allow all by default, and insert a
39+ // `Content-Policy-Directive` header to disable inline javascript.
40+ // External javascript will still be blocked the old way, by preventing the
41+ // resource from being fetched.
42+ // https://github.com/gorhill/httpswitchboard/issues/35
43+ chrome . contentSettings . javascript . set ( {
44+ primaryPattern : '*://*/*' ,
45+ setting : 'allow'
46+ } ) ;
47+
3848/******************************************************************************/
3949
4050function injectedCodeCallback ( r ) {
@@ -166,7 +176,10 @@ function onBeforeNavigateCallback(details) {
166176 return ;
167177 }
168178 var hostname = uriTools . hostnameFromURI ( details . url ) ;
169- setJavascript ( hostname , HTTPSB . whitelisted ( details . url , 'script' , hostname ) ) ;
179+
180+ // No longer needed, but I will just comment out for now.
181+ // https://github.com/gorhill/httpswitchboard/issues/35
182+ // setJavascript(hostname, HTTPSB.whitelisted(details.url, 'script', hostname));
170183}
171184
172185chrome . webNavigation . onBeforeNavigate . addListener ( onBeforeNavigateCallback ) ;
@@ -227,78 +240,3 @@ function onDisconnectHandler() {
227240
228241chrome . extension . onConnect . addListener ( onConnectHandler ) ;
229242
230- /******************************************************************************/
231-
232- chrome . contextMenus . create ( {
233- type : 'normal' ,
234- id : 'gdt-group0' ,
235- title : 'Temporarily whitelist ...' ,
236- documentUrlPatterns : [ 'http://*/*' , 'https://*/*' ]
237- } ,
238- function ( ) { }
239- ) ;
240-
241- chrome . contextMenus . create ( {
242- type : 'normal' ,
243- id : 'revertPermissions' ,
244- title : 'Remove all temporary permissions' ,
245- documentUrlPatterns : [ 'http://*/*' , 'https://*/*' ]
246- } ,
247- function ( ) { }
248- ) ;
249-
250- function contextMenuClickHandler ( info , tab ) {
251- // "If the click did not take place in a tab,
252- // "this parameter will be missing"
253- if ( ! tab ) {
254- return ;
255- }
256-
257- var pageURL = uriTools . normalizeURI ( tab . url ) ;
258- var pageDomain = uriTools . domainFromURI ( pageURL ) ;
259-
260- if ( ! pageDomain ) {
261- return ;
262- }
263-
264- switch ( info . menuItemId ) {
265- case 'gdt-group0' :
266- HTTPSB . whitelistTemporarily ( pageURL , '*' , pageDomain ) ;
267- smartReloadTab ( tab . id ) ;
268- break ;
269-
270- case 'revertPermissions' :
271- HTTPSB . revertPermissions ( ) ;
272- smartReloadTabs ( ) ;
273- break ;
274- }
275- }
276-
277- chrome . contextMenus . onClicked . addListener ( contextMenuClickHandler ) ;
278-
279- /******************************************************************************/
280-
281- function updateContextMenuHandler ( tabs ) {
282- if ( ! tabs . length ) {
283- return ;
284- }
285- var tab = tabs [ 0 ] ;
286- if ( ! tab . url || ! tab . url . length ) {
287- return ;
288- }
289- var pageUrl = uriTools . normalizeURI ( tab . url ) ;
290- var pageDomain = uriTools . domainFromURI ( pageUrl ) ;
291- var color = HTTPSB . evaluate ( pageUrl , '*' , pageDomain ) ;
292- chrome . contextMenus . update ( 'gdt-group0' , {
293- title : 'Temporarily whitelist *.' + pageDomain ,
294- enabled : color . charAt ( 0 ) !== 'g' && ! HTTPSB . off
295- } ) ;
296- chrome . contextMenus . update ( 'revertPermissions' , {
297- enabled : ! HTTPSB . off
298- } ) ;
299- }
300-
301- function updateContextMenu ( ) {
302- chrome . tabs . query ( { active : true } , updateContextMenuHandler ) ;
303- }
304-
0 commit comments