Re:Hotlinking to jquery.com will be disabled on January 31, ...
by axod on Friday December 31, 2010 @12:34PM
(#2055877)
<script>
var oldAlertFunction = window.alert;
window.alert = function(){};
</script>
<script src="crockford.com/json.library.js"></script>
Arms race, but just sayin'
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by alex_c on Friday December 31, 2010 @12:44PM
(#2055894)
The point would be to give webmasters a heads-up and time to fix their sites before hotlinking is disabled, not so much to prevent them from using the file.
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by axod on Friday December 31, 2010 @12:46PM
(#2055902)
Indeed. I was just being silly :)
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by nerfhammer on Friday December 31, 2010 @02:47PM
(#2056255)
Anyone smart enough to think of that would be smart enough not to hotlink
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by MBlume on Friday December 31, 2010 @01:22PM
(#2055991)
And if you want to avoid changing the rest of the page:
<script> var oldAlertFunction = window.alert; window.alert = function(){}; </script>
<script src="crockford.com/json.library.js"></script>
<script>
window.alert=oldAlertFunction;
</script>
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by orblivion on Friday December 31, 2010 @10:53AM
(#2055641)
If Crockford used it in production though, the alert() would be removed there, right? So someone could still in theory hotlink that.
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by jerf on Friday December 31, 2010 @12:34PM
(#2055876)
if (location.host.search(/crockford.com$/i) != -1) {
alert("Stop hotlinking me!")
}
I don't think you can fool that, but I'd love to hear about how I'm wrong.
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by hk9565 on Friday December 31, 2010 @04:26PM
(#2056508)
You can definitely fool that:
http://www.adambarth.com/papers/2009/adida-barth-jackson.pdf
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by adamdecaf on Friday December 31, 2010 @01:26PM
(#2056007)
window.alert = function () {};
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by tlrobinson on Friday December 31, 2010 @01:35PM
(#2056032)
if (location.host.search(/crockford.com$/i) != -1) {
throw "Stop hotlinking me!";
}
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by simonsarris on Saturday January 01, 2011 @12:36AM
(#2057285)
You code should read != 0 to have the desired effect.
And even then, this can bypass it:
var temp = String.prototype.search;
String.prototype.search = function() { return 0};
if (location.host.search(/crockford.com$/i) != 0) {
throw "Stop hotlinking me!";
}
String.prototype.search = temp;
Though that may cause other problems.
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by tlrobinson on Monday January 03, 2011 @01:52AM
(#2062416)
My point was that it's just a game of cat and mouse. I could come up with lots of workarounds for almost anything you throw at me. Example:
var expectedHost = "crockford.com";
if (expectedHost.length !== location.host)
throw "Stop hotlinking me!";
for (var i = 0; i < expectedHost.length; i++)
if (location.host[i] === expectedHost[i])
throw "Stop hotlinking me!";
(though it string[x] might not work in every browser)So thanks for further demonstrating my point!
But really, just check the referrer header.
Re:Hotlinking to jquery.com will be disabled on January 31, ...
by jerf on Friday December 31, 2010 @02:17PM
(#2056149)
Point. I was unclear in my phrasing, I was more looking into just not accidentally bypassing it. Deliberately bypassing it probably can't be stopped but really at that point you've already lost. Given what I've seen in the world somebody grabbing an existing proxy script and regexing out the check and never once stopping to think this is way worse than hosting the file yourself wouldn't even make me blink.
This would probably be the best way to transition. If they add an alert to their library and leave it up a week, most people should notice and fix it.