├── .gitignore ├── chrome ├── chrome.zip ├── img │ ├── icon128.png │ ├── icon16.png │ ├── icon19.png │ ├── icon38.png │ └── icon48.png ├── popup.html ├── js │ ├── content.tpl.js │ ├── background.js │ └── content.js └── manifest.json ├── bower.json ├── package.json ├── LICENSE ├── README.md ├── lib └── deb.js └── example └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /chrome/chrome.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/chrome.zip -------------------------------------------------------------------------------- /chrome/img/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/img/icon128.png -------------------------------------------------------------------------------- /chrome/img/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/img/icon16.png -------------------------------------------------------------------------------- /chrome/img/icon19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/img/icon19.png -------------------------------------------------------------------------------- /chrome/img/icon38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/img/icon38.png -------------------------------------------------------------------------------- /chrome/img/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krasimir/deb.js/master/chrome/img/icon48.png -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deb.js", 3 | "description": "Minimalistic JavaScript library for debugging in the browser.", 4 | "license": "MIT", 5 | "_source": "git://github.com/krasimir/deb.js.git", 6 | "homepage": "https://github.com/krasimir/deb.js", 7 | "main": "build/deb.min.js", 8 | "keywords": [ 9 | "javascript", 10 | "js", 11 | "lib", 12 | "debug", 13 | "browser", 14 | "debugger" 15 | ], 16 | "ignore": [ 17 | "/.*", 18 | "chrome", 19 | "example" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /chrome/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 26 | 27 | 28 |Add debjs to your URL to get Deb.js enabled.
29 | 30 | 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deb.js", 3 | "version": "0.0.1", 4 | "homepage": "https://github.com/krasimir/deb.js", 5 | "description": "Minimalistic JavaScript library for debugging in the browser", 6 | "author": { 7 | "name": "Krasimir Tsonev", 8 | "email": "info@krasimirtsonev.com", 9 | "url": "http://krasimirtsonev.com" 10 | }, 11 | "license": "MIT", 12 | "dependencies": { 13 | 14 | }, 15 | "devDependencies": { 16 | "uglify-js": "2.4.14" 17 | }, 18 | "keywords": [ 19 | "javascript", 20 | "browser", 21 | "debugger" 22 | ], 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/krasimir/deb.js" 26 | }, 27 | "scripts": { 28 | "build": "node ./build.js" 29 | } 30 | } -------------------------------------------------------------------------------- /chrome/js/content.tpl.js: -------------------------------------------------------------------------------- 1 | // Function to inject script into top of or 2 | function injectScript() { 3 | var s = document.createElement('script'); 4 | s.textContent = '{debjs}'; 5 | 6 | var root = document.head || document.documentElement; 7 | var newScript = root.insertBefore(s, root.firstChild); 8 | s.parentNode.removeChild(s); 9 | } 10 | 11 | // This logic decides if deb.js should be injected or not. 12 | if (sessionStorage.debJsState) injectScript(); 13 | 14 | // Listen for messages from background script 15 | chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { 16 | if (message === 'getState') { // Get debJsState 17 | sendResponse(sessionStorage.debJsState); 18 | } else if (typeof message.setState === 'string') { // Set debJsState 19 | sessionStorage.debJsState = message.setState; 20 | sendResponse(); 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /chrome/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Deb.js", 4 | "description": "The tiniest debugger in the world", 5 | "version": "0.0.5", 6 | "icons": { "16": "img/icon16.png", "48": "img/icon48.png", "128": "img/icon128.png" }, 7 | "browser_action": { 8 | "default_icon": { 9 | "19": "img/icon19.png", 10 | "38": "img/icon38.png" 11 | }, 12 | "default_title": "Deb.js" 13 | }, 14 | "permissions": [ 15 | "activeTab" 16 | ], 17 | "background": { 18 | "scripts": ["js/background.js"], 19 | "persistent": false 20 | }, 21 | "content_scripts": [ 22 | { 23 | "matches": ["http://*/*", "https://*/*"], 24 | "js": ["js/content.js"], 25 | "run_at": "document_start" 26 | } 27 | ], 28 | "web_accessible_resources": [ 29 | "js/deb.min.js" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /chrome/js/background.js: -------------------------------------------------------------------------------- 1 | function updateBadgeText(tabId, toggle) { 2 | if (typeof tabId !== 'number') return; // tabId is required 3 | 4 | chrome.tabs.sendMessage(tabId, 'getState', // Get state 5 | function(response) { // When state is retrieved... 6 | var state = response; 7 | 8 | if (toggle) state = !state; 9 | var badgeText = state ? 'ON' : ''; 10 | 11 | chrome.browserAction.setBadgeText({ // Update badge 12 | text: badgeText 13 | }); 14 | 15 | if (toggle) { 16 | chrome.tabs.sendMessage(tabId, { // Save state 17 | setState: badgeText 18 | }, function() { // When state is saved... 19 | chrome.tabs.reload(); // ...refresh page 20 | }); 21 | } 22 | }); 23 | } 24 | 25 | chrome.browserAction.onClicked.addListener(function(tab) { // On button click... 26 | updateBadgeText(tab.id, true); // ...(param 2 `true` => toggle value) 27 | }); 28 | 29 | chrome.tabs.onActivated.addListener(function(info) { // On active tab change... 30 | updateBadgeText(info.tabId); // ...update badge 31 | }); 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Krasimir Tsonev 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. -------------------------------------------------------------------------------- /chrome/js/content.js: -------------------------------------------------------------------------------- 1 | // Function to inject script into top of or 2 | function injectScript() { 3 | var s = document.createElement('script'); 4 | s.textContent = '!function(o,n){"function"==typeof define&&define.amd?define([],n):n()}(this,function(){Function.prototype.debc=function(o){return Function.prototype.deb.apply(this,[o,!0])},Function.prototype.deb=function(o,n){var t,e=function(){return"rgb("+(Math.floor(76*Math.random())+200)+","+(Math.floor(76*Math.random())+200)+","+(Math.floor(76*Math.random())+200)+")"},r=function(o,e,r){"undefined"!=typeof console&&(p&&"string"==typeof o?r!==!1&&o.indexOf("%20")<0?console[e?n?"groupCollapsed":"group":"log"]("%c"+o,"background:"+t+";"+r):console[e?n?"groupCollapsed":"group":"log"](o):console[e?"group":"log"](o))},i=function(){"undefined"!=typeof console&&console.groupEnd()},u=function(o){return o.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[0]},c=function(n,t,e){var c=u(e);if(0===n[0].indexOf("Error")&&(n=n.slice(1)),r(o+c+")",l),t&&t.length>0){r("arguments:",!0);for(var a=0;a