1. Kevin Wetzels
  2. dotjs-files

Commits

Kevin Wetzels  committed aca060d

Remove those damn previews from Google

  • Participants
  • Parent commits c0e62b9
  • Branches default

Comments (0)

Files changed (2)

File google.com.js

View file
 (function() {
 	
-	var counter = 0;
+	var counters = {};
+
+	var whenPresent = function(selector, cb, timeout, maxAttempts) {
+		timeout = timeout || 100;
+		maxAttempts = maxAttempts || 5;
+		var el = $(selector);
+		if (el.length) {
+			cb(el);
+		} else {
+			var count = counters[selector];
+			if (!count) {
+				count = 0;
+			}
+			if (count < maxAttempts) {
+				setTimeout(function() {
+					whenPresent(selector, cb, timeout, maxAttempts);
+				}, timeout);
+				counters[selector] = ++count;	
+			}
+		}
+	}
+
+	var clearPreview = function() {
+		whenPresent('#ires div.vspib', function(el) {
+			el.remove();
+		});
+	};
 
 	var clearLinks = function() {
-		var results = $('#ires');
-		if (results.length) {
-			$('a.l', results).removeAttr('onmousedown');
-		} else if (counter < 5) {
-			setTimeout(clearLinks, 100);
-			++counter;
-		}
-	}
+		whenPresent('#ires a.l', function(el) {
+			el.removeAttr('onmousedown');
+			// The preview chevrons seem to be loaded afterwards, so start 
+			// cleaning them up now
+			clearPreview();
+		});
+	};
 
 	clearLinks();
 

File setup.sh

View file
 #!/bin/sh
-
+rm encrypted.google.com.js
+rm google.be.js
 ln -sf google.com.js encrypted.google.com.js
 ln -sf google.com.js google.be.js