mp info
20 February 2016I've been meaning for ages to clean up my Chrome extension MP Info, which sort of worked except for one major problem. It's sole, simple idea is to highlight the names of British Members of Parliament on any webpage, and to show a tooltip with an (admittedly slightly confusing at the moment) voting record, with data drawn from the They Work For You API:
The problem was that not only was my extension highlighting the names of MPs, it was also highlighting all code displays in Github.
Thinking at first this had something to do with the third party highlight script I was using, but on inspecting Github's markup for the code element I found that it was contained in a table with the class name of highlight
, which happened to be the class name I was using to highlight MP's names. So it was just a case of my SASS seeing that table and applying the yellow background to it. All I had to do was change the class name I used in the highlight call:
$('body').highlight(mps[i].name, {
wordsOnly: true,
className: 'mpHighlight'
});
And all was right with the world again. You can get the Chrome extension here and pore over its arcane mysteries here.