A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

Add Javascript to a security protected page

If you want to run some JQuery (or any other script) on a page that doesn't have it already, you can load it like this in the web browser console:

var script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(script);

But on pages with a strict security policy, you may get an error:

Refused to load the script '......' because it violates the following Content Security Policy directive: .....

Solution: Edit the DOM and replace the security policy with this one:

<meta http-equiv="Content-Security-Policy" content="default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;">

(source)

Breakdown of policy from that guy:
  • default-src * self                 blob: data: gap:;
  • style-src   * self 'unsafe-inline' blob: data: gap:;
  • script-src  * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:;
  • object-src  * 'self'               blob: data: gap:;
  • img-src     * self 'unsafe-inline' blob: data: gap:;
  • connect-src self * 'unsafe-inline' blob: data: gap:;
  • frame-src   * self                 blob: data: gap:;
Hmm, that doesn't look quite right. Seems inconsistent.

Using your bastion server as a socks proxy

How to access web services via a jump host:
​
ssh -v -N -C -D 9090 username@bastion.example.com
​
* `-v` verbose, see any issues as they arise
* `-N` don't execute a remote command
* `-C` turn on compression
* `-D #` open a SOCKS proxy on this local port
​
Browser setup: FoxyProxy (Configure to "Use Enabled Proxies By Patterns and Order")

screenshot of foxyproxy settings

NOTE: It's a bad idea to route all web traffic through your company's bastion server / jump host. Only route the hosts you absolutely need to.

Or for command line stuff:

ssh -v -N -C -D 9090 mad@bastard.example.com
hpts -s 127.0.0.1:9090 -p 8989 --level info
export http_proxy=http://127.0.0.1:8989/
export https_proxy=http://127.0.0.1:8989/

URLs open in Safari instead of Chrome from Mac OSX Terminal

To set the correct default browser on OSX, go to System preferences | General | Default web browser.

If the default browser is correct but Terminal is still not behaving correctly, then change the default browser, and change it back again.

TIOA-TIOA FTW

(source)

Web developer browser plugins

Chrome:
  • Chrome itself doesn't require admin privileges to install
  • Chrome has dev tools built in - type F12 and select a tab e.g. Network, or right-click on the page and choose 'Inspect element'
  • chrome://net-internals/
  • Web developer plugin
  • Modify headers
Internet Explorer:
  • Internet Explorer should be installed by default
  • It has some dev tools built in - type F12 and then:
    • Menu: Find | Select element by click
    • Menu: Cache | View cookie information
    • Tab: Script | Console
    • Tab: Network (IE9 and later) | Go to detailed view | Double-click an item for headers and cookies
Standalone:
Non-GUI:
  • curl -D -
  • wget -S

Android: Don't refresh page when no signal

chrome://flags/#enable-offline-mode

and

chrome://flags/#enable-offline-load-stale-cache

Unfortunately this doesn't work anymore - those flags were experimental.
In fact I've switched to Firefox (which is also much faster on Android) because Chrome tabs kept annoyingly reloading when the phone had no signal.

Text-based web browsers

  • http://w3m.sourceforge.net/
  • http://lynx.browser.org/
  • http://www.jikos.cz/~mikulas/links/

Shortcuts in Firefox 2

You can set up a shortcut keyword by
  1. going to the properties of a bookmark in 'organize bookmarks',
  2. putting a %s as the wildcard in the URL
  3. setting a keyword for the shortcut
Then you can type the keyword and a wildcard in the address bar to load that url.

[full article]

Make Firefox 3 look like Firefox 2

From the neo-luddite department.