Created
January 8, 2012 11:44
-
-
Save XP1/1578081 to your computer and use it in GitHub Desktop.
Enhance Apple iTunes App Store: Forces iTunes detection in Opera. Autolaunches the app in iTunes from Opera.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Enhance Apple iTunes App Store | |
// @version 1.01 | |
// @description Forces iTunes detection in Opera. Autolaunches the app in iTunes from Opera. | |
// @author XP1 (https://github.com/XP1/) | |
// @namespace https://gist.github.com/1578081/ | |
// @include http*://itunes.apple.com/* | |
// @include http*://*.itunes.apple.com/* | |
// ==/UserScript== | |
// http://r.mzstatic.com/htmlResources/B435/web-storefront-preview.jsz | |
/*jslint browser: true, vars: true, white: true, maxerr: 50, indent: 4 */ | |
(function (console, window) | |
{ | |
"use strict"; | |
var userScript = { | |
name: "Enhance Apple iTunes App Store" | |
}; | |
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); | |
} | |
}; | |
function overrideSettings() | |
{ | |
function enable() | |
{ | |
return true; | |
} | |
var detect = window.its.detect; | |
detect.itunesDetected = enable; | |
detect.shouldAutolaunch = enable; | |
} | |
function initialize() | |
{ | |
var functions = [overrideSettings]; | |
var i = null; | |
var length = functions.length; | |
for (i = 0; i < length; i += 1) | |
{ | |
handleException(functions[i]); | |
} | |
} | |
window.addEventListener("DOMContentLoaded", removeEventListenerAfterFiring(1, initialize), false); | |
}(this.console, this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment