From fd63ee7c695ae95c4ed2212e9bb249d81b499cd9 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 24 Apr 2015 16:11:50 -0400 Subject: [PATCH] Re-edit w3m-reddit script with .mobile fix --- _posts/2013-06-04-w3m-reddit.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/_posts/2013-06-04-w3m-reddit.md b/_posts/2013-06-04-w3m-reddit.md index 311fc5e..ac9f791 100644 --- a/_posts/2013-06-04-w3m-reddit.md +++ b/_posts/2013-06-04-w3m-reddit.md @@ -45,8 +45,17 @@ done args+=("$@") for arg in "${args[@]}" ; do # Switch to mobile reddit - url=${arg/http:\/\/reddit.com/https:\/\/m.reddit.com} - url=${url/http:\/\/www.reddit.com/https:\/\/m.reddit.com} + url=$arg + mobile='.mobile' + if [[ $url =~ http:\/\/www.reddit.com || $url =~ http:\/\/reddit.com ]] + then + if [[ $url =~ \/$ ]] + then + url=$url$mobile + else + url=$url'/'$mobile + fi + fi # Fix double backslash error in comment uri for mobile reddit url=${url/\/\/comments/\/comments} if [[ $t == "1" ]]; then @@ -96,6 +105,6 @@ command-line. EDIT 04/25/2015: Reddit seems to have gotten rid of their old mobile reddit site and replaced it with a more modern version that unfortunately doesn't look as -good in w3m. It still gets rid of a lot of header junk that is present in the -desktop version, though. It also doesn't work over http, so I edited the script -to always switch to https. +good in w3m. However, the old mobile site is still accessable by adding a +".mobile" to the end of urls. The script above has been edited to reflect this +change.