3 ms·
As someone not at all familiar with writing Safari extensions, this (https://github.com/aaronbrethorst/NoBitcoin/blob/master/NoBitcoin.safariextension/nobitcoin
by mcrittenden 15y ago
As someone not at all familiar with writing Safari extensions, this (https://github.com/aaronbrethorst/NoBitcoin/blob/master/NoBitcoin.safariextension/nobitcoin.js https://github.com/aaronbrethorst/NoBitcoin/blob/master/NoBi...) looks really really overcomplicated for something that seems like it would only take a few lines of JS to do in a bookmarklet or Greasemonkey script (assuming it's literally just hiding any story that has "bitcoin" in the title - this might be a bad assumption as I can't try it out myself).
Are all Safari extensions this complex?
- aaronbrethorst 15y agoI wanted CSS selector support, and so I just copied and pasted in Zepto with some minor hacks to prevent conflicts with pg's $ function. I'm sure there are easier ways to do this, but I've never written one before, either, and wanted to spend as little time as possible writing it.
- eridius 15y agoIt seems like a remarkably bad idea to modify the prototypes of the built-in classes inside a Safari Extension. It's bad enough to do that in a library, but at least the web page is making a deliberate choice to use that library. When you put it in an extension, you've now modified the prototypes of the built-in classes in a way that affects the page, but without the page ever being aware of this. What happens if your function is named the same as one the page tried to define, but behaves differently? For the record, document.querySelectorAll() is built-in and can do selector matching, and the only other thing you use Zepto for (adding classes) is trivially done manually.
- aaronbrethorst 15y agoThanks for the tip. As I'm sure you could tell from the code, this was the result of about 15 minutes of work this morning (from generating the CSR to get my certificate to tossing it onto GitHub). If I ever go back and touch this repo again, I'll use querySelectAll().