├── .gitignore ├── LICENSE ├── README.md ├── app.js ├── icons ├── 40 │ └── app.png ├── 48 │ └── app.png └── 128 │ └── app.png └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore IDE created files and directories. 2 | /.settings 3 | /.buildpath 4 | /.project 5 | /.idea 6 | 7 | # Ignore created XPI packages. 8 | disable-javascript@pacassi.ch.xpi 9 | 10 | # Ignore OS files. 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 David Pacassi Torrico 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Mozilla Add-on](https://img.shields.io/amo/v/view-page-source-mobile.svg)](https://addons.mozilla.org/en-US/firefox/addon/view-page-source-mobile/) 2 | [![Mozilla Add-on](https://img.shields.io/amo/users/view-page-source-mobile.svg)](https://addons.mozilla.org/en-US/firefox/addon/view-page-source-mobile/) 3 | [![Mozilla Add-on](https://img.shields.io/amo/stars/view-page-source-mobile.svg)](https://addons.mozilla.org/en-US/firefox/addon/view-page-source-mobile/) 4 | [![license](https://img.shields.io/github/license/dpacassi/view-page-source-mobile.svg)](https://github.com/dpacassi/view-page-source-mobile/blob/master/LICENSE) 5 | 6 | # View Page Source (Mobile) 7 | This small web extension adds a `View Page Source` menu item to Firefox for Android as well as an icon on desktop browsers. 8 | While the usage on desktop browsers might be questionable, it is really handy on mobile devices. 9 | 10 | ## Supported browsers 11 | - [Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/view-page-source-mobile/) (Desktop & Firefox for Android) 12 | 13 | ## Usage 14 | Simply click the icon or menu item to view the page source. 15 | 16 | ## Why to use this web extension 17 | The code is completely **open source**, you can also use the unpacked version of this web extension if you prefer. 18 | No data of you will ever be logged and the web extension asks only for needed permissions. 19 | Pull requests are **welcome**! 20 | 21 | ## Support 22 | If you need any assistance or find any bugs, feel free to contact me directly via email or create a 23 | new issue on the [projects GitHub page](https://github.com/dpacassi/view-page-source-mobile). 24 | 25 | ## Other web extensions 26 | - [Disable JavaScript](https://github.com/dpacassi/disable-javascript) 27 | 28 | ## Maintainer 29 | - [David Pacassi Torrico](https://pacassi.ch/) _(Web extension implementation, maintenance, support)_ 30 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var browser = browser; 4 | 5 | (function(browser) { 6 | // Local variables. 7 | var browser = browser; 8 | 9 | // If browser is not defined, the plugin was loaded into Google Chrome. 10 | if (typeof browser === 'undefined') { 11 | browser = chrome; 12 | } 13 | 14 | /** 15 | * Checks if the page source for a given url can be shown. 16 | */ 17 | function isValidPageSourceUrl(url) { 18 | return !url.startsWith('view-source:'); 19 | } 20 | 21 | /** 22 | * Opens a new tab with the page source. 23 | */ 24 | browser.browserAction.onClicked.addListener(function(tab) { 25 | var url = tab.url; 26 | 27 | if (isValidPageSourceUrl(url)) { 28 | browser.tabs.create({ 29 | url: 'view-source:' + url, 30 | index: tab.index + 1 31 | }); 32 | } 33 | }); 34 | 35 | /** 36 | * Enables or disables the app icon accordingly when changing the url. 37 | */ 38 | browser.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { 39 | if (typeof browser.browserAction.disable !== 'undefined') { 40 | var url = changeInfo.url || tab.url; 41 | 42 | if (isValidPageSourceUrl(url)) { 43 | browser.browserAction.enable(tabId); 44 | } else { 45 | browser.browserAction.disable(tabId); 46 | } 47 | } 48 | }); 49 | })(browser); 50 | -------------------------------------------------------------------------------- /icons/128/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dpacassi/view-page-source-mobile/7c91eb99c28d2c2965c4a7afac2a3e03a1f9c624/icons/128/app.png -------------------------------------------------------------------------------- /icons/40/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dpacassi/view-page-source-mobile/7c91eb99c28d2c2965c4a7afac2a3e03a1f9c624/icons/40/app.png -------------------------------------------------------------------------------- /icons/48/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dpacassi/view-page-source-mobile/7c91eb99c28d2c2965c4a7afac2a3e03a1f9c624/icons/48/app.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "David Pacassi Torrico", 3 | "manifest_version": 2, 4 | "name": "View Page Source (Mobile)", 5 | "version": "1.0.1", 6 | "description": "Adds the ability to open the page source in a new tab via button (Desktop) or menu (Firefox for Android).", 7 | "homepage_url": "https://github.com/dpacassi/view-page-source-mobile", 8 | "icons": { 9 | "40": "icons/40/app.png", 10 | "48": "icons/48/app.png", 11 | "128": "icons/128/app.png" 12 | }, 13 | "browser_action": { 14 | "default_icon": { 15 | "40": "icons/40/app.png", 16 | "48": "icons/48/app.png", 17 | "128": "icons/128/app.png" 18 | }, 19 | "default_title": "View Page Source" 20 | }, 21 | "background": { 22 | "scripts": [ 23 | "app.js" 24 | ], 25 | "persistent": true 26 | }, 27 | "permissions": [ 28 | "", 29 | "activeTab", 30 | "tabs" 31 | ] 32 | } 33 | --------------------------------------------------------------------------------