Last active
October 12, 2015 12:25
-
-
Save thorwe/a04340f0a3519659f248 to your computer and use it in GitHub Desktop.
Get Overwolf App Directory (using IO Plugin)
This file contains 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
// add 'Extensions' to manifest permission object | |
// have one of the two IO Plugins available as pluginIO | |
var getMyWebAppDirectory = function(callback) { | |
var mypath = pluginIO().LOCALAPPDATA + "\\Overwolf\\Extensions"; | |
var fallback = function() { | |
var pluginStr = window.location.host; | |
pluginStr = pluginStr.replace("Window_Extension_", ""); | |
var index = pluginStr.lastIndexOf("_"); | |
if (index != -1) { | |
pluginStr = pluginStr.slice(0,index); | |
} | |
mypath += "\\" + pluginStr + "\\" + "1.0.0"; | |
} | |
overwolf.extensions.current.getManifest(function(manifestObj) { | |
if (typeof manifestObj === "undefined") { | |
console.error("Could not get Manifest."); | |
fallback(); | |
} else if (typeof manifestObj.UID === "undefined") { | |
console.error("Manifest has no UID."); | |
fallback(); | |
} else if (typeof manifestObj.meta === "undefined") { | |
console.error("Manifest has no meta object."); | |
fallback(); | |
} else { | |
mypath += "\\" + manifestObj.UID + "\\" + manifestObj.meta.version; | |
} | |
pluginIO().isDirectory( | |
mypath, | |
function(status) { | |
callback(mypath, status); | |
} | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment