Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some awesome motha fuckin code for werkin on chrome extensions!

  • Loading branch information...
commit 3eb8de370f63a3a53cddfdd3960175f5333593ec 0 parents
@devinrhode2 authored
1  .gitattributes
@@ -0,0 +1 @@
+* text=auto
52 .gitignore
@@ -0,0 +1,52 @@
+# Read about how to use .gitignore: http://h5bp.com/ae
+
+# Numerous always-ignore extensions
+*.diff
+*.err
+*.orig
+*.log
+*.rej
+*.swo
+*.swp
+*.vi
+*~
+*.sass-cache
+
+# OS or Editor folders
+.DS_Store
+._*
+Thumbs.db
+.cache
+.project
+.settings
+.tmproj
+nbproject
+*.sublime-project
+*.sublime-workspace
+
+# Dreamweaver added files
+_notes
+dwsync.xml
+
+# Komodo
+*.komodoproject
+.komodotools
+
+# Espresso
+*.esproj
+*.espressostorage
+
+# Rubinius
+*.rbc
+
+# Folders to ignore
+.hg
+.svn
+.CVS
+intermediate
+publish
+.idea
+
+# build script local files
+build/buildinfo.properties
+build/config/buildinfo.properties
32 README.markdown
@@ -0,0 +1,32 @@
+Extension-include.js
+=================
+
+Some general motha fuckin functions for extension development, TOTALLY undocumented because it's for muah until you message me!
+
+Install
+---------------
+
+npm install extension-include
+
+OOO!
+
+Creator
+---------------
+
+Is Devin Rhode. He's OCD about stuff, and started his career in Silicon Valley at age 19, follow him on twitter here: http://Twitter.com/DevinRhode2 and subscribe to his public posts on facebook at: http://Facebook.com/Devin.Rhode404
+
+Throughout most of the internet, he is DevinRhode2 (here, StackOverflow, gmail, .. EVERYWHERE)
+
+
+License
+---------------
+
+(The MIT License)
+
+Copyright (c) 2012 Devin Rhode <DevinRhode2@Gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
194 extension-include.js
@@ -0,0 +1,194 @@
+/* By Devin Rhode (devinrhode2@gmail.com)
+ * General library-esque functions!
+ *
+ * $.class is a wrapper on document.getElementsByClassName
+ * $.id is a wrapper on getElementById
+ * log('things like', trickyVaribles);
+ * fail('When some bad shit occured.');
+ *
+ * has: Does a string have a certain substring inside it? returns boolean
+ */
+
+(function includeJSStrict(){
+'use strict';
+
+window.$ = window.$ || {};
+$.class = function getElementsByClassNameWrapper(elements){
+ return document.getElementsByClassName(elements);
+};
+$.id = function getElementByIdWrapper(elements){
+ return document.getElementById(elements);
+};
+$.tag = function getElementsByTagNameWrapper(elements){
+ return document.getElementsByTagName(elements);
+};
+HTMLElement.prototype.class = HTMLElement.prototype.getElementsByClassName;
+HTMLElement.prototype.id = HTMLElement.prototype.getElementById;
+HTMLElement.prototype.tag = HTMLElement.prototype.getElementsByTagName;
+
+String.prototype.contains = function StringPrototypeHas(string) {
+ return this.indexOf(string) > -1;
+};
+
+String.prototype.toBoolean = function StringPrototypeToBoolean() {
+ if (this === 'false') {
+ return false;
+ } else if (this === 'true') {
+ return true;
+ } else {
+ throw 'string is not \'true\' or \'false\'';
+ }
+};
+
+var ajax = {};
+ajax.x = function() {
+ return new XMLHttpRequest;
+};
+ajax.send = function(u, f, m, a) {
+ var x = ajax.x();
+ x.open(m, u, true);
+ x.onreadystatechange = function() {
+ if(x.readyState == 4) {
+ f(x.responseText, x);
+ }
+ };
+ if(m === "POST") {
+ x.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
+ }
+ x.send(a)
+};
+window.POST = function POST(url, func, args) {
+ ajax.send(url, func, "POST", args);
+};
+
+window.GET = function GET(url, callback){
+ ajax.send(url,callback,'GET');
+};
+
+window.masterHistory = function masterHistory(){
+ //have a master switch on caller.name === 'f' (log) || 'warn' || 'fail' || 'error'
+};
+
+//fail, program cannot continue. Alert a message, and kill it
+window.fail = function fail(message){
+ masterHistory(arguments);
+ alert(message);
+ throw message;
+};
+
+//from HTML5 boilerplate. Paul Irish is awesome. I have no idea why the function name is 'f'...
+window.log = function f() {
+ masterHistory(arguments);
+ if (typeof debug !== 'undefined' && debug) {
+ if (typeof console !== 'undefined') { // with if (this.console) I was getting "Uncaught TypeError: Cannot read property 'console' of undefined"
+ var args = arguments;
+ var newarr;
+
+ try {
+ args.callee = f.caller;
+ } catch(e) {
+
+ }
+
+ newarr = [].slice.call(args);
+
+ if (typeof console.log === 'object') {
+ log.apply.call(console.log, console, newarr);
+ } else {
+ console.log.apply(console, newarr);//
+ }
+ }
+ }
+};
+
+
+//Some common pitfall that is handled. Application will continue fine.
+window.warn = function warn(message){
+ masterHistory(arguments);
+ debug && console.warn(message);
+ return message;
+};
+//some error where the program will continue, but this scenario really shouldn't be occuring
+window.error = function error(message){
+ masterHistory(arguments);
+ debug && console.error(message);
+ return message;
+};
+
+//more specific
+//kiss metrics push!
+window.kmpush = function kmpush(){
+ if (typeof _kmq === 'undefined') {
+ window._kmq = [];
+ }
+ var argsArray = [].slice.call(arguments);
+ if (argsArray.length === 1) {
+ _kmq.push(['record', argsArray[0]]);
+ } else {
+ _kmq.push(argsArray);
+ }
+};
+
+window.storageDefault = function storageDefault(arg1, arg2){
+ if (typeof arg1 === 'string') {
+ if (localStorage.getItem(arg1) === null) {
+ localStorage.setItem(arg1, arg2);
+ }
+ } else {
+ if (typeof arg1 === 'object') {
+ for (var key in arg1) {
+ if (localStorage.getItem(key) === null) {
+ localStorage.setItem(arg1, arg1[key]);
+ }
+ }
+ } else {
+ fail('storageDefault expects an object or 2 string arguments');
+ }
+ }
+};
+
+
+//very extension specific:
+//coolest method ever!
+$.createElement = function createElement(element, props, attributes) {
+ var element = document.createElement(element);
+ if (typeof props !== 'undefined') {
+ for (var prop in props) {
+ element[prop] = props[prop];
+ }
+ if (typeof attributes !== 'undefined') {
+ for (var attr in attributes) {
+ element.setAttribute(attr, attributes[attr]);
+ }
+ }
+ }
+ return element;
+};
+
+//UPDATE 1.1.0
+window.style = function style(cssString){
+ var s = document.createElement('style');
+ s.innerHTML = cssString;
+ s.setAttribute('from', 'an extension');
+ document.documentElement.appendChild(s);
+};
+
+window.runInPage = function runInPage() {
+ var script = document.createElement('script');
+ script.innerHTML = '';
+ for (task in arguments) {
+ if (typeof arguments[task] === 'string') {
+ script.innerHTML += arguments[task];
+ } else if (typeof arguments[task] === 'function') {
+ script.innerHTML += '(' + arguments[task] + '())';
+ }
+ }
+ try {
+ document.documentElement.appendChild(script);
+ } catch (e) {
+ console.error('CAUGHT ERROR: ', e, 'on:', script.innerHTML);
+ }
+ //script.removeNode(true); ?
+}
+
+}());
17 package.json
@@ -0,0 +1,17 @@
+{
+ "name": "extension-include",
+ "version": "1.0.9",
+ "description": "Some really nifty functions for non-jQuery chrome extension development",
+ "author": "Devin Rhode <devinrhode2@gmail.com>",
+ "main": "extension-include.js",
+ "preferGlobal": false,
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "repository": {
+ "url": ""
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.