├── .gitignore ├── README.md ├── readingmode.crx ├── screenshot.png └── src ├── background.js ├── icon.png ├── iconoff.png └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | # VIM 2 | *.swp 3 | *~ 4 | *.pem 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Reading Mode 2 | ============ 3 | 4 | Chrome extension that makes the [internet fast again](http://idlewords.com/talks/website_obesity.htm). Defaults to canceling all requests other than the main_frame: no JavaScript, no images, no XHR, no ads (not even an empty HTTP request to let them count eyeballs). No more loading 3MB websites to read <500 words. Everything reads like Linux kernel documentation. 5 | 6 | ![](screenshot.png) 7 | 8 | Recommended for use with user-specified custom stylesheets. Probably best to modify the rules to match your own browsing habits (e.g., reading mode disabled for Gmail, etc.). 9 | 10 | Install 11 | ------- 12 | Download [readingmode.crx](https://github.com/srpeck/readingmode/blob/master/readingmode.crx?raw=true) and drop it into Chrome. 13 | 14 | Modify 15 | ------ 16 | Download [source files as zip](https://github.com/srpeck/readingmode/zipball/master), go to [chrome://extensions](chrome://extensions), enable Developer mode, and Load unpacked extension. 17 | -------------------------------------------------------------------------------- /readingmode.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srpeck/readingmode/76588f576961944993a2648e1ca796ef2b87249a/readingmode.crx -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srpeck/readingmode/76588f576961944993a2648e1ca796ef2b87249a/screenshot.png -------------------------------------------------------------------------------- /src/background.js: -------------------------------------------------------------------------------- 1 | // Consider pairing with user-specified custom stylesheet based on your reading preferences (e.g., font, wrapping/centering, day/night mode, etc.) 2 | var disabledTabs=[],currentTab; 3 | chrome.webRequest.onBeforeRequest.addListener( 4 | function(x){ 5 | // Consider adding a list of rules/URLs based on your browsing habits (e.g., Gmail never goes to reading mode, allow images from base domain, etc.) 6 | if(disabledTabs.indexOf(x.tabId)>=0)return; // Reading mode on by default, toggled off by tab 7 | if(x.url.indexOf("chrome-extension://")===0)return; // Allow button icon to be updated 8 | if(x.type!=="main_frame"){return{cancel:true};} 9 | }, 10 | {urls:[""],}, 11 | ["blocking"] 12 | ); 13 | chrome.browserAction.onClicked.addListener(toggleMode); 14 | chrome.commands.onCommand.addListener(function(x){if(x==="toggle-reading")toggleMode();}); 15 | chrome.tabs.onUpdated.addListener(function(_,p,t){if(p.status==="loading"&&t.selected)updateIcon();}); 16 | chrome.tabs.onHighlighted.addListener(function(){updateIcon();}); 17 | chrome.windows.onFocusChanged.addListener(function(){updateIcon();}); 18 | chrome.windows.getCurrent(function(){updateIcon();}); 19 | function setIcon(mode){chrome.browserAction.setIcon({path:"icon"+mode+".png"});} 20 | function toggleMode(){ 21 | var x=disabledTabs.indexOf(currentTab); 22 | if(x<0){ 23 | disabledTabs.push(currentTab); 24 | setIcon("off"); 25 | }else{ 26 | disabledTabs.splice(x,1); 27 | setIcon(""); 28 | } 29 | chrome.tabs.reload(currentTab,{bypassCache:false}); 30 | } 31 | function updateIcon(){ 32 | chrome.tabs.query({'active':true,'windowId':chrome.windows.WINDOW_ID_CURRENT}, 33 | function(t){if(t[0])setIcon(disabledTabs.indexOf(currentTab=t[0].id)<0?"off":"");}); 34 | } 35 | -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srpeck/readingmode/76588f576961944993a2648e1ca796ef2b87249a/src/icon.png -------------------------------------------------------------------------------- /src/iconoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srpeck/readingmode/76588f576961944993a2648e1ca796ef2b87249a/src/iconoff.png -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"Reading Mode", 3 | "version":"1.0", 4 | "homepage_url":"https://github.com/srpeck/readingmode", 5 | "description":"main_frame only reading mode", 6 | "browser_action":{ 7 | "default_icon":"icon.png", 8 | "default_title":"Toggle reading mode" 9 | }, 10 | "permissions":["activeTab","webRequest","webRequestBlocking",""], 11 | "background":{ 12 | "scripts":["background.js"] 13 | }, 14 | "commands":{ 15 | "toggle-reading":{ 16 | "suggested_key":{"default":"Alt+Shift+R","mac":"Command+Shift+R"}, 17 | "description":"Toggle reading mode" 18 | } 19 | }, 20 | "manifest_version":2 21 | } 22 | --------------------------------------------------------------------------------