Back & Forth

Published 2011-05-26 on Farid Zakaria's Blog

Let's try another route

No sooner had I posted my fix for my Chrome HypeMachine Extension, it had seemed to be broken again. I guess an easy fix deserved was going to get an easy work-around.

Since my "fix" was simply just renaming the CSS element, it was also just as easy for them to also just change the javascript to match my names.

The 'ext_load' function mentioned earlier was also moved to within a larger function. I'm guessing to stop me from simply overloading the function...

This time I thought I would try something else and see where it takes me.

Will this work?

I just pushed a change to the Chrome Extension that will hopefully avoid the back & forth of changing CSS element names by randomizing them instead. Here is a little snippet of how I randomized the CSS element names. The reference for the code I used can be found here.

function randomStringGenerator()
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = "";
    for (var i = 0 ; i < string_length ; i++)
        var rnum = Math.floor(Math.random()* chars.length);
        randomstring += chars.charAt(rnum);
    return randomstring;

var cssElementToRandom =  randomStringGenerator();
var css = document.createElement('style');
css.type = 'text/css';
var styles = '.'+cssElementToRandom+'{ width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;	border-top: 10px solid #494949; }';

if (css.styleSheet) css.styleSheet.cssText = styles;
else css.appendChild(document.createTextNode(styles));


Your move.