├── package.json ├── example.js └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-google-chrome", 3 | "description": "Mac OS X bindings for Google Chrome", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "NodObjC": "0.0.15" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/pose/node-google-chrome.git" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | var $ = require('NodObjC'); 2 | 3 | $.framework('Foundation'); 4 | $.framework('ScriptingBridge'); 5 | $.framework('AppKit'); 6 | 7 | // Setup the recommended NSAutoreleasePool instance 8 | var pool = $.NSAutoreleasePool('alloc')('init'); 9 | 10 | // NSStrings and JavaScript Strings are distinct objects, you must create an 11 | // NSString from a JS String when an Objective-C class method requires one. 12 | var string = $.NSString('stringWithUTF8String', 'com.google.Chrome'); 13 | 14 | var chrome = $.SBApplication('applicationWithBundleIdentifier', string); 15 | 16 | chrome = chrome('windows')('objectAtIndex', 0)('tabs'); 17 | 18 | var windowCount = chrome('count'); 19 | 20 | for (var i = 0; i < windowCount; i++) { 21 | console.log(chrome('objectAtIndex', i)('URL')); 22 | console.log(chrome('objectAtIndex', i)('executeJavascript', $.NSString('stringWithUTF8String','alert("hi")'))); 23 | } 24 | 25 | pool('drain'); 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-google-chrome 2 | 3 | Mac OS X bindings for Google Chrome (in node.js) 4 | 5 | ## Credits 6 | 7 | This module was inspired by [chrome cli](https://github.com/prasmussen/chrome-cli/) 8 | 9 | 10 | ## License 11 | (The MIT License) 12 | 13 | Copyright (c) 2014 Alberto Pose < albertopose at gmail.com > 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | THE SOFTWARE. 32 | --------------------------------------------------------------------------------