Commits

Nik Cubrilovic  committed cb22100

initial import

  • Participants

Comments (0)

Files changed (8)

+Copyright 2010 Nik Cubrilovic <nikcub@gmail.com>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright notice, this list of
+      conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright notice, this list
+      of conditions and the following disclaimer in the documentation and/or other materials
+      provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY NIK CUBRILOVIC ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NIK CUBRILOVIC OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those of the
+authors and should not be interpreted as representing official policies, either expressed
+or implied, of NIK CUBRILOVIC.
+# Blockplus
+
+Removes all Google Plus links, icons and notifiers from other Google properties so
+you can get back to work instead of screwing around on social networks.
+
+## Version
+
+Latest release is 0.0.9 (7th July 2011)
+
+## Install
+
+Click here to install for Chrome:
+
+[http://nikcub.appspot.com/projects/blockplus.crx](http://nikcub.appspot.com/projects/blockplus.crx)
+
+Give the extension permission, and click ok.
+
+## Issues
+
+Please log issues you find at:
+
+[http://github.com/nikcub/fidelio/issues](http://github.com/nikcub/fidelio/issues)
+
+or email me on nikcub at gmail.com
+
+## Source
+
+Source code for the project is on BitBucket:
+
+[http://bitbucket.org/nik/blockplus](http://bitbucket.org/nik/blockplus)
+
+## Changelog
+
+0.0.9 (7th July 2011):
+	* initial release
+		
+## TODO
+
+ * Suggestions? Email me.
+
+## License
+
+Copyright 2010 Nik Cubrilovic [http://nikcub.appspot.com]. All Rights Reserved.
+
+Use of this source code is governed by a 3-clause BSD license.
+See the LICENSE file for details.

File chrome/build/blockplus-0.0.9.crx

Binary file added.

File chrome/src/content.js

+/*
+  Copyright 2010 Nik Cubrilovic [http://nikcub.appspot.com]. All Rights Reserved.
+
+  Use of this source code is governed by a 3-clause BSD license.
+  See the LICENSE file for details.
+*/
+
+(function (document) {
+
+  var BlockPlus = {
+    
+    debugLevel: false,
+    
+    startTime: false,
+    
+    // brutal. bit of a double-tap, the last one finishes it off
+    plusClasses: ['a.gbzt', 'a.gbml1', "a[href*='plus.google.com']"],
+    
+    init: function (options) {
+      BlockPlus.debug("Started BlockPlus");
+      if(arguments.length > 0 && options instanceof Object) {
+        BlockPlus.debugLevel = options.debug;
+      }
+      
+      document.addEventListener('beforeload', BlockPlus.checkSite, true);
+      document.addEventListener('load', BlockPlus.hideClasses, true);
+    },
+
+    onEnable: function(ext) {
+      console.log("BlockPlus Enabled");
+    },
+    
+    debug: function(msg) {
+      if(BlockPlus.debugLevel && typeof console == 'object') {
+        console.info(msg);
+      }
+    },
+    
+    hideClasses: function(ev) {
+      if(document.location.hostname == 'plus.google.com') {
+        return ;
+      }
+      for(cls in BlockPlus.plusClasses) {
+        var ce = document.querySelectorAll(BlockPlus.plusClasses[cls]);
+        BlockPlus.debug("Checking:", BlockPlus.plusClasses[cls], "found:", ce.length );
+        if(ce.length > 0) {
+          for(c in ce) {
+            // console.info(ce[c], ce[c].href);
+            if(BlockPlus.getHost(ce[c].href) == 'plus.google.com') {
+              BlockPlus.debug("Blocking Class:", ce[c].href);
+              ce[c].style.display = 'none';
+            }
+          }
+        } 
+      }
+    },
+    
+    checkSite: function(ev) {
+      hs = BlockPlus.getHost(ev.url);
+      
+      if(hs == 'plus.google.com' && document.location.host != hs) {
+        ev.preventDefault();
+        BlockPlus.debug('Blocked:', hs);
+      }
+    },
+    
+    chromeSender: function(rec, msg, cb) {
+      msg = msg || "";
+      cb = (typeof cb == 'undefined') ? function(x){return x;} : cb;
+      chrome.extension.sendRequest({rec: rec, msg: msg}, cb);
+    },
+    
+    siteMatch: function(hostname) {
+      for(site in this.siteList) {
+        if(!this.hostMatch(this.siteList[site], hostname))
+          return true;
+      }
+      return false;
+    },
+    
+    hostMatch: function(src1, src2) {
+      var url1 = this.reverseString(src1);
+      var url2 = this.reverseString(src2);
+      var sub = (url1.length < url2.length) ? url1 : url2;
+      
+      return (url1.substr(0, sub.length) != url2.substr(0, sub.length));
+    },
+    
+    reverseString: function (str) {
+      return str.split('').reverse().join('');
+    },
+    
+    // getHost will expand the scheme to set a full URL and then extract hostname
+    getHost: function (url) {
+      orin = url;
+      if(url == '' || typeof url !== 'string')
+        return '';
+      if(url.substr(0, 2) == '//') {
+        url = document.location.protocol + url;
+      }
+      if(url.substr(0, 1) == '/') {
+        url = document.location.origin + url;
+      }
+      var re = new RegExp('^(?:f|ht)tp(?:s)?\://([^/]+)', 'im');
+      t = url.match(re);
+      return t[1].toString().toLowerCase();
+    },
+    
+    getStorage: function (key) {
+      var result = localStorage[key];
+      if(typeof(result) == "undefined")
+        return [];
+      else
+        return JSON.parse(result);
+    },
+
+    setStorage: function (key, value) {
+      localStorage[key] = JSON.stringify(value);
+    },
+    
+    cookieRead: function(name) {
+      var nameEQ = name + "=";
+      var ca = document.cookie.split(';');
+      for(var i=0;i < ca.length;i++) {
+        var c = ca[i];
+        while (c.charAt(0)==' ') c = c.substring(1,c.length);
+        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+      }
+      return null;
+    },
+      
+    cookieWrite: function(name, val) {
+      expires = "";
+      document.cookie = name + "=" + val + expires + "; path=/";
+    },
+    
+    logTime: function Timer() {
+      this.start_ = new Date();
+
+      this.elapsed = function() {
+        return (new Date()) - this.start_;
+      };
+
+      this.reset = function() {
+        this.start_ = new Date();
+      };
+    }
+  };
+  
+  BlockPlus.init.prototype = BlockPlus;
+  
+  try {
+    var options = { debug: false };
+    if(document.location.hash == 'bp_debug' || BlockPlus.cookieRead('bp_debug')) {
+      BlockPlus.cookieWrite('bp_debug', true);
+      options.debug = true;
+    }
+    if(document.location.hash == 'bp_debug_stop') {
+      BlockPlus.cookieWrite('bp_debug', '');
+    }
+    console.info("cookie", BlockPlus.cookieRead('bp_debug'));
+    bp = window.BlockPlus = new BlockPlus.init(options);
+  } catch(Error) {
+    console.error('Error: ' + arguments[0] + ' ' + Error.message);
+    console.error(Error.stack);
+  }
+    
+})(document);

File chrome/src/img/blockplus-128.png

Added
New image

File chrome/src/img/blockplus-19.png

Added
New image

File chrome/src/img/blockplus-48.png

Added
New image

File chrome/src/manifest.json

+/*
+	Copyright 2010 Nik Cubrilovic [http://nikcub.appspot.com]. All Rights Reserved.
+
+	Use of this source code is governed by a 3-clause BSD license.
+	See the LICENSE file for details.
+*/
+{
+	"name": "BlockPlus",
+	"version": "0.0.9",
+	"description": "Block Google plus toolbar from all non-plus sites.",
+	"update_url": "http://nikcub.appspot.com/projects/blockplus/updates.xml",
+	"content_scripts": [
+		{
+			"all_frames": true,
+			"js": [ "content.js" ],
+			"matches": [ "http://*.google.com/*", "https://*.google.com/*" ],
+			"run_at": "document_start"
+		}
+	],
+	"icons" : {
+		"19" : "img/blockplus-19.png",
+		"48" : "img/blockplus-48.png",
+		"128" : "img/blockplus-128.png"
+	}	
+}