Last active
November 4, 2015 12:28
-
-
Save adaliabooks/601638505d28fa899a41 to your computer and use it in GitHub Desktop.
Utility functions
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
function contentEval(source) { | |
// Check for function input. | |
if ('function' == typeof source) { | |
// Execute this function with no arguments, by adding parentheses. | |
// One set around the function, required for valid syntax, and a | |
// second empty set calls the surrounded function. | |
source = '(' + source + ')();' | |
} | |
// Create a script node holding this source code. | |
var script = document.createElement('script'); | |
script.setAttribute("type", "application/javascript"); | |
script.textContent = source; | |
// Insert the script node into the page, so it will run, and immediately | |
// remove it to clean up. | |
document.body.appendChild(script); | |
document.body.removeChild(script); | |
} | |
function executeFunctionByName(functionName, context /*, args */) { | |
var args = [].slice.call(arguments).splice(2); | |
var namespaces = functionName.split("."); | |
var func = namespaces.pop(); | |
for(var i = 0; i < namespaces.length; i++) { | |
context = context[namespaces[i]]; | |
} | |
return context[func].apply(this, args); | |
} | |
/* | |
$(document).on('debugLog', function(e, message) { | |
debugLogger.debugLog(message); | |
}); | |
$(document).on('runFunctionInScript', function (e, functionName, context, arguments) { | |
executeFunctionByName(functionName, context, arguments); | |
}); | |
*/ | |
/* | |
Gog clear updates function | |
http://www.gog.com/forum/general/those_updated_numbers_just_wont_vanish/post9 | |
!function(){var o=angular.element(document).injector(),t=o.get("accountProductsRepository"),e=o.get("accountProductDetails"),n =t._products;for(productId in n){var c=n[productId];c.updates>0&&(console.log("Clearing updates status for: "+c.title),e.requestGameDetails(c.id).then(function(){console.log("Done.")},function(){console.log("Error...") }))}}(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment