Skip to content

Instantly share code, notes, and snippets.

@XP1
Created January 8, 2012 09:05
Show Gist options
  • Save XP1/1577789 to your computer and use it in GitHub Desktop.
Save XP1/1577789 to your computer and use it in GitHub Desktop.
Fix Etsy: Disables ajax uploading on Etsy to make the photo uploader work in Opera 11.
// ==UserScript==
// @name Fix Etsy
// @version 1.01
// @description Disables ajax uploading on Etsy to make the photo uploader work in Opera 11.
// @author XP1 (https://github.com/XP1/)
// @namespace https://gist.github.com/1577789/
// @include http*://etsy.com/your/listings/create*
// @include http*://*.etsy.com/your/listings/create*
// ==/UserScript==
/*jslint browser: true, vars: true, white: true, maxerr: 50, indent: 4 */
(function (console, window)
{
"use strict";
var userScript = {
name: "Fix Etsy"
};
function removeEventListenerAfterFiring(numberOfTimes, callback)
{
var remaining = numberOfTimes;
return function listener(event)
{
remaining -= 1;
if (remaining <= 0)
{
var target = event.target;
var type = event.type;
target.removeEventListener(type, listener, false);
target.removeEventListener(type, listener, true);
}
callback();
};
}
var handleException = function handleException(theFunction)
{
try
{
theFunction();
}
catch (exception)
{
console.error("[" + userScript.name + "]: Exception: " + exception + "\n\nStack:\n" + exception.stack + "\n\nStacktrace:\n" + exception.stacktrace);
}
};
/**
* Disables ajax upload because it will not work in Opera 11.
*
* Opera 11 does not support XMLHttpRequest 2, which allows sending a file blob as an argument:
* http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-send-method
*/
function disableAjaxUpload()
{
function disable()
{
return false;
}
var Etsy = window.Etsy;
handleException(function ()
{
Etsy.FileUploader.prototype.supportsAJAX = disable;
});
handleException(function ()
{
Etsy.YourEtsy.Listings.Photo.Upload.prototype.supportsAJAX = disable;
});
}
window.addEventListener("DOMContentLoaded", removeEventListenerAfterFiring(1, disableAjaxUpload), false);
}(this.console, this));
@XP1
Copy link
Author

XP1 commented Jan 8, 2012

I posted this user JS in these threads:

Can't upload photos in Opera:
http://my.opera.com/community/forums/topic.dml?id=1057592

Uploading photos using Opera:
http://www.etsy.com/teams/7718/site-help/discuss/8744722/

Browser Opera has problem in uploading pictures by using the New Listing Version:
http://www.etsy.com/teams/7720/bugs/discuss/7646941/

@XP1
Copy link
Author

XP1 commented May 29, 2012

This user JS is no longer necessary. Etsy has updated its codebase to disable the ajax uploader in Opera.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment