Posts Tagged ‘nytimes’

Google search current page bookmarklet

Thursday, May 23rd, 2013

Here’s a javascript bookmarklet for googlin’ the title of the current page your viewing:


javascript:(function(){window.location.href="http://google.com/search?q="+document.title;})()

Drag me onto your bookmark bar.

Then when you’re at a sit that blocks regular visiting but allows entrance through a google search—cough, cough, nytimes.com—you can quickly google the title and click the inevitably top link.

Ignore nytimes paywall with simple client-side javascript, or applescript

Thursday, April 21st, 2011

Today was my first experience with the New York Times paywall. It manifested as an html overlay on top of the article I wanted to read. The article seemed to have fully loaded which made me think that if I could just get rid of the overlay I’d be able to read it.

This turned out to be the exactly case. I just zapped the div containing the overly (properly labeled id='overlay' and restored the overflow of the main page (to get scrolling back).

ignore nytimes paywall

This is easily accomplished with three lines of client side javascript:


document.getElementById('overlay').parentNode.innerHTML = '';
document.body.style['overflow-x'] = 'auto';
document.body.style['overflow-y'] = 'auto';

There are many ways of issuing your own javascript on pages opened in your browser, whatever that might be.

For me on a mac with safari, wrapping the above into a little applescript is easiest. I save this in a file called Ignore-nytimes-paywall.scpt:


tell application "Safari"
	try
		set doc to front document
		do JavaScript "document.getElementById('overlay').parentNode.innerHTML = '';" in doc
		do JavaScript "document.body.style['overflow-x'] = 'auto';" in doc
		do JavaScript "document.body.style['overflow-y'] = 'auto';" in doc
	on error errText number errNum
	end try
end tell

It seems that coming up with your own hack for knocking down the nytimes paywall is the trend these days. We’re all blowing our technological Joshua trumpets ;-).

Update: I’m now more convinced that nytimes is just using this paywall as an experiment. Ignoring the paywall is even easier than I thought:

Readers need only remove “?gwh=numbers” from the URL. They can also clear their browser caches, or switch browsers as soon as they see the subscription prompt. All three of these simple fixes will let them continue reading.

Source

Update:
Seems the paywall organization has changed a little bit and now the client side javascript should be:


document.getElementById('regiwallBackground').style.display = 'none';
document.getElementById('regiwallOverlay').style.display = 'none';
document.body.parentElement.style.overflow = 'scroll';

Log in to nytimes.com download crossword puzzle and convert to pdf script

Tuesday, January 12th, 2010

I have given my girlfriend a subscription to the New York Times crossword puzzle which she (graciously?) allows me to use. Using the help of the decode_crossword.pl perl script, I have made a bash script to log in to nytimes.com, grab today’s puzzle in .puz format and convert it to pdf so I can easily print and view it. Here’s the script (replace userid and password with your own):


#!/bin/bash

if test -z $1 ; then
  date=`date +%b%d%y`
else
  date="$1"
fi

#
# log in to nytimes and save cookies
wget --post-data \
  "USERID=youremail%40gmail.com&PASSWORD=yourpassword&is_continue=true" \
  --save-cookies=cookies.txt --keep-session-cookies \
  -O /dev/null\
  http://www.nytimes.com/auth/login &>/dev/null

# download puzzle
wget --load-cookies=cookies.txt \
  http://select.nytimes.com/premium/xword/$date.puz &>/dev/null

# get rid of cookies
rm cookies.txt

# convert to pdf
./decode_crossword -P $date.puz | ps2pdf - $date.pdf &>/dev/null

# get rid of .puz version
rm $date.puz

Update: NYTimes changed their login routine so now you should use something like:


#!/bin/bash

if test -z $1 ; then
  date=`date +%b%d%y`
else
  date="$1"
fi

wget \
  --no-check-certificate \
  https://myaccount.nytimes.com/auth/login \
  -O login.html \
  &>/dev/null
 
token=`grep token login.html | sed -e "s/^.*value=\"\([A-z0-9]*\)\".*$/\\1/g"`
expires=`grep expires login.html | sed -e "s/^.*value=\"\([A-z0-9]*\)\".*$/\\1/g"`

# log in as annie, should get rid of her password from this
wget --post-data \
  "userid=youremail%40gmail.com&password=yourpassword&is_continue=false&remember=true&token=$token&expires=$expires" \
  --save-cookies=cookies.txt --keep-session-cookies \
  --no-check-certificate \
  -O /dev/null \
  https://myaccount.nytimes.com/auth/login \
  &>/dev/null

# download puzzle
wget --load-cookies=cookies.txt \
  http://select.nytimes.com/premium/xword/$date.puz &>/dev/null

# get rid of cookies
rm cookies.txt
# get rid of login cache
rm login.html

# convert to pdf
./decode_crossword -P $date.puz | ps2pdf - $date.pdf &>/dev/null

# get rid of .puz version
rm $date.puz