elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Crear un script para un juego FLASH
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Crear un script para un juego FLASH  (Leído 2,238 veces)
Treiaron

Desconectado Desconectado

Mensajes: 5


Ver Perfil
Crear un script para un juego FLASH
« en: 26 Febrero 2016, 15:47 pm »

Tengo una duda, yo juego a un juego Flash, llamado boombang este juego trata de dar puñetazos algo infantil parece pero acaba entreteniendo, yo lo que quiero saber es como puedo hacer para poder dar puñetazos sin que a mi me den, es decir que envié una cantidad exagerada de Packets para que mis clicks sean mayores, en este juego para poder dar tienes que tener su Ficha es decir, tener al jugador selecionado, y a mi me gustaría poder dar sin tener a ese personaje selecioando, seria de gran ayuda si me podriais decir como, este juego utiliza una CyptoGrafia RC4, y de hay no se nada mas gracias.
De este juego saque esto no se si sirve para algo

/**
 * @param {!InjectedScriptHostClass} InjectedScriptHost
 * @param {!Window|!WorkerGlobalScope} inspectedGlobalObject
 * @param {number} injectedScriptId
 */
(function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) {

/**
 * Protect against Object overwritten by the user code.
 * @suppress {duplicate}
 */
var Object = /** @type {function(new:Object, *=)} */ ({}.constructor);

/**
 * @param {!Array.<T>} array
 * @param {...} var_args
 * @template T
 */
function push(array, var_args)
{
    for (var i = 1; i < arguments.length; ++i)
        array[array.length] = arguments;
}

/**
 * @param {(!Arguments.<T>|!NodeList)} array
 * @param {number=} index
 * @return {!Array.<T>}
 * @template T
 */
function slice(array, index)
{
    var result = [];
    for (var i = index || 0, j = 0; i < array.length; ++i, ++j)
        result[j] = array;
    return result;
}

/**
 * @param {!Array.<T>} array1
 * @param {!Array.<T>} array2
 * @return {!Array.<T>}
 * @template T
 */
function concat(array1, array2)
{
    var result = [];
    for (var i = 0; i < array1.length; ++i)
        push(result, array1);
    for (var i = 0; i < array2.length; ++i)
        push(result, array2);
    return result;
}

/**
 * @param {*} obj
 * @return {string}
 * @suppress {uselessCode}
 */
function toString(obj)
{
    // We don't use String(obj) because String could be overridden.
    // Also the ("" + obj) expression may throw.
    try {
        return "" + obj;
    } catch (e) {
        var name = InjectedScriptHost.internalConstructorName(obj) || InjectedScriptHost.subtype(obj) || (typeof obj);
        return "#<" + name + ">";
    }
}

/**
 * @param {*} obj
 * @return {string}
 */
function toStringDescription(obj)
{
    if (typeof obj === "number" && obj === 0 && 1 / obj < 0)
        return "-0"; // Negative zero.
    return toString(obj);
}

/**
 * Please use this bind, not the one from Function.prototype
 * @param {function(...)} func
 * @param {?Object} thisObject
 * @param {...} var_args
 * @return {function(...)}
 */
function bind(func, thisObject, var_args)
{
    var args = slice(arguments, 2);

    /**
     * @param {...} var_args
     */
    function bound(var_args)
    {
        return InjectedScriptHost.callFunction(func, thisObject, concat(args, slice(arguments)));
    }
    bound.toString = function()
    {
        return "bound: " + toString(func);
    };
    return bound;
}

/**
 * @param {T} obj
 * @return {T}
 * @template T
 */
function nullifyObjectProto(obj)
{
    if (obj && typeof obj === "object")
        obj.__proto__ = null;
    return obj;
}

/**
 * @param {number|string} obj
 * @return {boolean}
 */
function isUInt32(obj)
{
    if (typeof obj === "number")
        return obj >>> 0 === obj && (obj > 0 || 1 / obj > 0);
    return "" + (obj >>> 0) === obj;
}

/**
 * FireBug's array detection.
 * @param {*} obj
 * @return {boolean}
 */
function isArrayLike(obj)
{
    if (typeof obj !== "object")
        return false;
    try {
        if (typeof obj.splice === "function") {
            var len = obj.length;
            return typeof len === "number" && isUInt32(len);
        }
    } catch (e) {
    }
    return false;
}

/**
 * @param {number} a
 * @param {number} b
 * @return {number}
 */
function max(a, b)
{
    return a > b ? a : b;
}

/**
 * FIXME: Remove once ES6 is supported natively by JS compiler.
 * @param {*} obj
 * @return {boolean}
 */
function isSymbol(obj)
{
    var type = typeof obj;
    return (type === "symbol");
}

/**
 * @param {string} str
 * @param {string} searchElement
 * @param {number=} fromIndex
 * @return {number}
 */
function indexOf(str, searchElement, fromIndex)
{
    var len = str.length;
    var n = fromIndex || 0;
    var k = max(n >= 0 ? n : len + n, 0);

    while (k < len) {
        if (str[k] === searchElement)
            return k;
        ++k;
    }
    return -1;
}

/**
 * DOM Attributes which have observable side effect on getter, in the form of
 *   {interfaceName1: {attributeName1: true,
 *                     attributeName2: true,
 *                     ...},
 *    interfaceName2: {...},
 *    ...}
 * @type {!Object<string, !Object<string, boolean>>}
 * @const
 */
var domAttributesWithObservableSideEffectOnGet = nullifyObjectProto({});
domAttributesWithObservableSideEffectOnGet["Request"] = nullifyObjectProto({});
domAttributesWithObservableSideEffectOnGet["Request"]["body"] = true;
domAttributesWithObservableSideEffectOnGet["Response"] = nullifyObjectProto({});
domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true;

/**
 * @param {!Object} object
 * @param {string} attribute
 * @return {boolean}
 */
function doesAttributeHaveObservableSideEffectOnGet(object, attribute)
{
    for (var interfaceName in domAttributesWithObservableSideEffectOnGet) {
        var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(function(object, interfaceName) {
            return /* suppressBlacklist */ typeof inspectedGlobalObject[interfaceName] === "function" && object instanceof inspectedGlobalObject[interfaceName];
        }, null, [object, interfaceName]);
        if (isInstance) {
            return attribute in domAttributesWithObservableSideEffectOnGet[interfaceName];
        }
    }
    return false;
}

/**
 * @constructor
 */
var InjectedScript = function()
{
}

/**
 * @type {!Object.<string, boolean>}
 * @const
 */
InjectedScript.primitiveTypes = {
    "undefined": true,
    "boolean": true,
    "number": true,
    "string": true,
    __proto__: null
}

InjectedScript.prototype = {
    /**
     * @param {*} object
     * @return {boolean}
     */
    isPrimitiveValue: function(object)
    {
        // FIXME(33716): typeof document.all is always 'undefined'.
        return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllCollection(object);
    },

    /**
     * @param {*} object
     * @param {string} groupName
     * @param {boolean} canAccessInspectedGlobalObject
     * @param {boolean} generatePreview
     * @return {!RuntimeAgent.RemoteObject}
     */
    wrapObject: function(object, groupName, canAccessInspectedGlobalObject, generatePreview)
    {
        if (canAccessInspectedGlobalObject)
            return this._wrapObject(object, groupName, false, generatePreview);
        return this._fallbackWrapper(object);
    },

    /**
     * @param {*} object
     * @return {!RuntimeAgent.RemoteObject}
     */
    _fallbackWrapper: function(object)
    {
        var result = { __proto__: null };
        result.type = typeof object;
        if (this.isPrimitiveValue(object))
            result.value = object;
        else
            result.description = toString(object);
        return /** @type {!RuntimeAgent.RemoteObject} */ (result);
    },

    /**
     * @param {boolean} canAccessInspectedGlobalObject
     * @param {!Object} table
     * @param {!Array.<string>|string|boolean} columns
     * @return {!RuntimeAgent.RemoteObject}
     */
    wrapTable: function(canAccessInspectedGlobalObject, table, columns)
    {
        if (!canAccessInspectedGlobalObject)
            return this._fallbackWrapper(table);
        var columnNames = null;
        if (typeof columns === "string")
            columns = [columns];
        if (InjectedScriptHost.subtype(columns) === "array") {
            columnNames = [];
            for (var i = 0; i < columns.length; ++i)
                columnNames = toString(columns);
        }
        return this._wrapObject(table, "console", false, true, columnNames, true);
    },

    /**
     * @param {*} object
     * @return {*}
     */
    _inspect: function(object)
    {
        if (arguments.length === 0)
            return;

        var objectId = this._wrapObject(object, "");
        var hints = { __proto__: null };

        InjectedScriptHost.inspect(objectId, hints);
        return object;
    },

    /**
     * This method cannot throw.
     * @param {*} object
     * @param {string=} objectGroupName
     * @param {boolean=} forceValueType
     * @param {boolean=} generatePreview
     * @param {?Array.<string>=} columnNames
     * @param {boolean=} isTable
     * @param {boolean=} doNotBind
     * @param {*=} customObjectConfig
     * @return {!RuntimeAgent.RemoteObject}
     * @suppress {checkTypes}
     */
    _wrapObject: function(object, objectGroupName, forceValueType, generatePreview, columnNames, isTable, doNotBind, customObjectConfig)
    {
        try {
            return new InjectedScript.RemoteObject(object, objectGroupName, doNotBind, forceValueType, generatePreview, columnNames, isTable, undefined, customObjectConfig);
        } catch (e) {
            try {
                var description = injectedScript._describe(e);
            } catch (ex) {
                var description = "<failed to convert exception to string>";
            }
            return new InjectedScript.RemoteObject(description);
        }
    },

    /**
     * @param {!Object|symbol} object
     * @param {string=} objectGroupName
     * @return {string}
     */
    _bind: function(object, objectGroupName)
    {
        var id = InjectedScriptHost.bind(object, objectGroupName || "");
        return "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":" + id + "}";
    },

    /**
     * @param {string} objectId
     * @return {!Object}
     */
    _parseObjectId: function(objectId)
    {
        return nullifyObjectProto(/** @type {!Object} */ (InjectedScriptHost.eval("(" + objectId + ")")));
    },

    clearLastEvaluationResult: function()
    {
        delete this._lastResult;
    },

    /**
     * @param {string} objectId
     * @param {boolean} ownProperties
     * @param {boolean} accessorPropertiesOnly
     * @param {boolean} generatePreview
     * @return {!Array.<!RuntimeAgent.PropertyDescriptor>|boolean}
     */
    getProperties: function(objectId, ownProperties, accessorPropertiesOnly, generatePreview)
    {
        var parsedObjectId = this._parseObjectId(objectId);
        var object = this._objectForId(parsedObjectId);
        var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedObjectId.id);

        if (!this._isDefined(object) || isSymbol(object))
            return false;
        object = /** @type {!Object} */ (object);
        var descriptors = [];
        var iter = this._propertyDescriptors(object, ownProperties, accessorPropertiesOnly, undefined);
        // Go over properties, wrap object values.
        for (var descriptor of iter) {
            if ("get" in descriptor)
                descriptor.get = this._wrapObject(descriptor.get, objectGroupName);
            if ("set" in descriptor)
                descriptor.set = this._wrapObject(descriptor.set, objectGroupName);
            if ("value" in descriptor)
                descriptor.value = this._wrapObject(descriptor.value, objectGroupName, false, generatePreview);
            if (!("configurable" in descriptor))
                descriptor.configurable = false;
            if (!("enumerable" in descriptor))
                descriptor.enumerable = false;
            if ("symbol" in descriptor)
                descriptor.symbol = this._wrapObject(descriptor.symbol, objectGroupName);
            push(descriptors, descriptor);
        }
        return descriptors;
    },

    /**
     * @param {string} objectId
     * @return {!Array.<!Object>|boolean}
     */
    getInternalProperties: function(objectId)
    {
        var parsedObjectId = this._parseObjectId(objectId);
        var object = this._objectForId(parsedObjectId);
        var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedObjectId.id);
        if (!this._isDefined(object) || isSymbol(object))
            return false;
        object = /** @type {!Object} */ (object);
        var descriptors = [];
        var internalProperties = InjectedScriptHost.getInternalProperties(object);
        if (internalProperties) {
            for (var i = 0; i < internalProperties.length; i += 2) {
                var descriptor = {
                    name: internalProperties,
                    value: this._wrapObject(internalProperties[i + 1], objectGroupName),
                    __proto__: null
                };
                push(descriptors, descriptor);
            }
        }
        return descriptors;
    },

    /**
     * @param {string} functionId
     * @return {!DebuggerAgent.FunctionDetails|string}
     */
    getFunctionDetails: function(functionId)
    {
        var parsedFunctionId = this._parseObjectId(functionId);
        var func = this._objectForId(parsedFunctionId);
        if (typeof func !== "function")
            return "Cannot resolve function by id.";
        var details = nullifyObjectProto(/** @type {!DebuggerAgent.FunctionDetails} */ (InjectedScriptHost.functionDetails(func)));
        if ("rawScopes" in details) {
            var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedFunctionId.id);
            var rawScopes = details["rawScopes"];
            delete details["rawScopes"];
            var scopes = [];
            for (var i = 0; i < rawScopes.length; ++i)
                scopes = InjectedScript.CallFrameProxy._createScopeJson(rawScopes.type, rawScopes.name, rawScopes.object, objectGroupName);
            details.scopeChain = scopes;
        }
        return details;
    },

    /**
     * @param {string} objectId
     * @return {!DebuggerAgent.GeneratorObjectDetails|string}
     */
    getGeneratorObjectDetails: function(objectId)
    {
        var parsedObjectId = this._parseObjectId(objectId);
        var object = this._objectForId(parsedObjectId);
        if (!object || typeof object !== "object")
            return "Could not find object with given id";
        var details = nullifyObjectProto(/** @type {?DebuggerAgent.GeneratorObjectDetails} */ (InjectedScriptHost.generatorObjectDetails(object)));
        if (!details)
            return "Object is not a generator";
        var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedObjectId.id);
        details["function"] = this._wrapObject(details["function"], objectGroupName);
        return details;
    },

    /**
     * @param {string} objectId
     * @return {!Array.<!Object>|string}
     */
    getCollectionEntries: function(objectId)
    {
        var parsedObjectId = this._parseObjectId(objectId);
        var object = this._objectForId(parsedObjectId);
        if (!object || typeof object !== "object")
            return "Could not find object with given id";
        var entries = InjectedScriptHost.collectionEntries(object);
        if (!entries)
            return "Object with given id is not a collection";
        var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedObjectId.id);
        for (var i = 0; i < entries.length; ++i) {
            var entry = nullifyObjectProto(entries);
            if ("key" in entry)
                entry.key = this._wrapObject(entry.key, objectGroupName);
            entry.value = this._wrapObject(entry.value, objectGroupName);
            entries = entry;
        }
        return entries;
    },

    /**
     * @param {!Object} object
     * @param {boolean=} ownProperties
     * @param {boolean=} accessorPropertiesOnly
     * @param {?Array.<string>=} propertyNamesOnly
     */
    _propertyDescriptors: function*(object, ownProperties, accessorPropertiesOnly, propertyNamesOnly)
    {
        var propertyProcessed = { __proto__: null };

        /**
         * @param {?Object} o
         * @param {!Iterable.<string|symbol>|!Array.<string|symbol>} properties
         */
        function* process(o, properties)
        {
            for (var property of properties) {
                if (propertyProcessed[property])
                    continue;

                var name = property;
                if (isSymbol(property))
                    name = /** @type {string} */ (injectedScript._describe(property));

                try {
                    propertyProcessed[property] = true;
                    var descriptor = nullifyObjectProto(InjectedScriptHost.suppressWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property]));
                    if (descriptor) {
                        if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor))
                            continue;
                        if ("get" in descriptor && "set" in descriptor && name != "__proto__" && InjectedScriptHost.isDOMWrapper(object) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
                            descriptor.value = InjectedScriptHost.suppressWarningsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name]);
                            delete descriptor.get;
                            delete descriptor.set;
                        }
                    } else {
                        // Not all bindings provide proper descriptors. Fall back to the writable, configurable property.
                        if (accessorPropertiesOnly)
                            continue;
                        try {
                            descriptor = { name: name, value: o[property], writable: false, configurable: false, enumerable: false, __proto__: null };
                            if (o === object)
                                descriptor.isOwn = true;
                            yield descriptor;
                        } catch (e) {
                            // Silent catch.
                        }
                        continue;
                    }
                } catch (e) {
                    if (accessorPropertiesOnly)
                        continue;
                    var descriptor = { __proto__: null };
                    descriptor.value = e;
                    descriptor.wasThrown = true;
                }

                descriptor.name = name;
                if (o === object)
                    descriptor.isOwn = true;
                if (isSymbol(property))
                    descriptor.symbol = property;
                yield descriptor;
            }
        }

        /**
         * @param {number} length
         */
        function* arrayIndexNames(length)
        {
            for (var i = 0; i < length; ++i)
                yield "" + i;
        }

        if (propertyNamesOnly) {
            for (var i = 0; i < propertyNamesOnly.length; ++i) {
                var name = propertyNamesOnly;
                for (var o = object; this._isDefined(o); o = o.__proto__) {
                    if (InjectedScriptHost.suppressWarningsAndCallFunction(Object.prototype.hasOwnProperty, o, [name])) {
                        for (var descriptor of process(o, [name]))
                            yield descriptor;
                        break;
                    }
                    if (ownProperties)
                        break;
                }
            }
            return;
        }

        var skipGetOwnPropertyNames;
        try {
            skipGetOwnPropertyNames = InjectedScriptHost.isTypedArray(object) && object.length > 500000;
        } catch (e) {
        }

        for (var o = object; this._isDefined(o); o = o.__proto__) {
            if (skipGetOwnPropertyNames && o === object) {
                // Avoid OOM crashes from getting all own property names of a large TypedArray.
                for (var descriptor of process(o, arrayIndexNames(o.length)))
                    yield descriptor;
            } else {
                // First call Object.keys() to enforce ordering of the property descriptors.
                for (var descriptor of process(o, Object.keys(/** @type {!Object} */ (o))))
                    yield descriptor;
                for (var descriptor of process(o, Object.getOwnPropertyNames(/** @type {!Object} */ (o))))
                    yield descriptor;
            }
            if (Object.getOwnPropertySymbols) {
                for (var descriptor of process(o, Object.getOwnPropertySymbols(/** @type {!Object} */ (o))))
                    yield descriptor;
            }
            if (ownProperties) {
                if (object.__proto__ && !accessorPropertiesOnly)
                    yield { name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true, __proto__: null };
                break;
            }
        }
    },

    /**
     * @param {string} expression
     * @param {string} objectGroup
     * @param {boolean} injectCommandLineAPI
     * @param {boolean} returnByValue
     * @param {boolean} generatePreview
     * @return {*}
     */
    evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
    {
        return this._evaluateAndWrap(null, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview);
    },

    /**
     * @param {string} objectId
     * @param {string} expression
     * @param {string} args
     * @param {boolean} returnByValue
     * @return {!Object|string}
     */
    callFunctionOn: function(objectId, expression, args, returnByValue)
    {
        var parsedObjectId = this._parseObjectId(objectId);
        var object = this._objectForId(parsedObjectId);
        if (!this._isDefined(object))
            return "Could not find object with given id";

        if (args) {
            var resolvedArgs = [];
            var callArgs = /** @type {!Array.<!RuntimeAgent.CallArgument>} */ (InjectedScriptHost.eval(args));
            for (var i = 0; i < callArgs.length; ++i) {
                try {
                    resolvedArgs = this._resolveCallArgument(callArgs);
                } catch (e) {
                    return toString(e);
                }
            }
        }

        var objectGroup = InjectedScriptHost.idToObjectGroupName(parsedObjectId.id);

        /**
         * @suppressReceiverCheck
         * @param {*} object
         * @param {boolean=} forceValueType
         * @param {boolean=} generatePreview
         * @param {?Array.<string>=} columnNames
         * @param {boolean=} isTable
         * @param {*=} customObjectConfig
         * @return {!RuntimeAgent.RemoteObject}
         * @this {InjectedScript}
         */
        function wrap(object, forceValueType, generatePreview, columnNames, isTable, customObjectConfig)
        {
            return this._wrapObject(object, objectGroup, forceValueType, generatePreview, columnNames, isTable, false, customObjectConfig);
        }

        try {

            var remoteObjectAPI = { bindRemoteObject: bind(wrap, this), __proto__: null};
            InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__remoteObjectAPI", remoteObjectAPI);

            var func = InjectedScriptHost.eval("with (typeof __remoteObjectAPI !== 'undefined' ? __remoteObjectAPI : { __proto__: null }) {(" + expression + ")}");
            if (typeof func !== "function")
                return "Given expression does not evaluate to a function";

            return { wasThrown: false,
                     result: this._wrapObject(InjectedScriptHost.callFunction(func, object, resolvedArgs), objectGroup, returnByValue),
                     __proto__: null };
        } catch (e) {
            return this._createThrownValue(e, objectGroup, false);
        } finally {
            try {
                delete inspectedGlobalObject["__remoteObjectAPI"];
            } catch(e) {
            }
        }
    },

    /**
     * @param {string|undefined} objectGroupName
     * @param {*} jsonMLObject
     * @throws {string} error message
     */
    _substituteObjectTagsInCustomPreview: function(objectGroupName, jsonMLObject)
    {
        var maxCustomPreviewRecursionDepth = 20;
        this._customPreviewRecursionDepth = (this._customPreviewRecursionDepth || 0) + 1
        try {
            if (this._customPreviewRecursionDepth >= maxCustomPreviewRecursionDepth)
                throw new Error("Too deep hierarchy of inlined custom previews");

            if (!isArrayLike(jsonMLObject))
                return;

            if (jsonMLObject[0] === "object") {
                var attributes = jsonMLObject[1];
                var originObject = attributes["object"];
                var config = attributes["config"];
                if (typeof originObject === "undefined")
                    throw new Error("Illegal format: obligatory attribute \"object\" isn't specified");

                jsonMLObject[1] = this._wrapObject(originObject, objectGroupName, false, false, null, false, false, config);
                return;
            }

            for (var i = 0; i < jsonMLObject.length; ++i)
                this._substituteObjectTagsInCustomPreview(objectGroupName, jsonMLObject);
        } finally {
            this._customPreviewRecursionDepth--;
        }
    },

    /**
     * Resolves a value from CallArgument description.
     * @param {!RuntimeAgent.CallArgument} callArgumentJson
     * @return {*} resolved value
     * @throws {string} error message
     */
    _resolveCallArgument: function(callArgumentJson)
    {
        callArgumentJson = nullifyObjectProto(callArgumentJson);
        var objectId = callArgumentJson.objectId;
        if (objectId) {
            var parsedArgId = this._parseObjectId(objectId);
            if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScriptId)
                throw "Arguments should belong to the same javascript world as the target object.";

            var resolvedArg = this._objectForId(parsedArgId);
            if (!this._isDefined(resolvedArg))
                throw "Could not find object with given id";

            return resolvedArg;
        } else if ("value" in callArgumentJson) {
            var value = callArgumentJson.value;
            if (callArgumentJson.type === "number" && typeof value !== "number")
                value = Number(value);
            return value;
        }
        return undefined;
    },

    /**
     * @param {?JavaScriptCallFrame} callFrame
     * @param {string} expression
     * @param {string} objectGroup
     * @param {boolean} injectCommandLineAPI
     * @param {boolean} returnByValue
     * @param {boolean} generatePreview
     * @param {!Array.<!Object>=} scopeChain
     * @return {!Object}
     */
    _evaluateAndWrap: function(callFrame, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, scopeChain)
    {
        var wrappedResult = this._evaluateOn(callFrame, objectGroup, expression, injectCommandLineAPI, scopeChain);
        if (!wrappedResult.exceptionDetails) {
            return { wasThrown: false,
                     result: this._wrapObject(wrappedResult.result, objectGroup, returnByValue, generatePreview),
                     __proto__: null };
        }
        return this._createThrownValue(wrappedResult.result, objectGroup, generatePreview, wrappedResult.exceptionDetails);
    },

    /**
     * @param {*} value
     * @param {string|undefined} objectGroup
     * @param {boolean} generatePreview
     * @param {!DebuggerAgent.ExceptionDetails=} exceptionDetails
     * @return {!Object}
     */
    _createThrownValue: function(value, objectGroup, generatePreview, exceptionDetails)
    {
        var remoteObject = this._wrapObject(value, objectGroup, false, generatePreview && InjectedScriptHost.subtype(value) !== "error");
        if (!remoteObject.description){
            try {
                remoteObject.description = toStringDescription(value);
            } catch (e) {}
        }
        return { wasThrown: true, result: remoteObject, exceptionDetails: exceptionDetails, __proto__: null };
    },

    /**
     * @param {?JavaScriptCallFrame} callFrame
     * @param {string} objectGroup
     * @param {string} expression
     * @param {boolean} injectCommandLineAPI
     * @param {!Array.<!Object>=} scopeChain
     * @return {*}
     */
    _evaluateOn: function(callFrame, objectGroup, expression, injectCommandLineAPI, scopeChain)
    {
        // Only install command line api object for the time of evaluation.
        // Surround the expression in with statements to inject our command line API so that
        // the window object properties still take more precedent than our API functions.

        var scopeExtensionForEval = (callFrame && injectCommandLineAPI) ? new CommandLineAPI(this._commandLineAPIImpl, callFrame) : undefined;

        injectCommandLineAPI = !scopeExtensionForEval && !callFrame && injectCommandLineAPI && !("__commandLineAPI" in inspectedGlobalObject);
        var injectScopeChain = scopeChain && scopeChain.length && !("__scopeChainForEval" in inspectedGlobalObject);

        try {
            var prefix = "";
            var suffix = "";
            if (injectCommandLineAPI) {
                InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__commandLineAPI", new CommandLineAPI(this._commandLineAPIImpl, callFrame));
                prefix = "with (typeof __commandLineAPI !== 'undefined' ? __commandLineAPI : { __proto__: null }) {";
                suffix = "}";
            }
            if (injectScopeChain) {
                InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__scopeChainForEval", scopeChain);
                for (var i = 0; i < scopeChain.length; ++i) {
                    prefix = "with (typeof __scopeChainForEval !== 'undefined' ? __scopeChainForEval[" + i + "] : { __proto__: null }) {" + (suffix ? " " : "") + prefix;
                    if (suffix)
                        suffix += " }";
                    else
                        suffix = "}";
                }
            }

            if (prefix)
                expression = prefix + "\n" + expression + "\n" + suffix;
            var wrappedResult = callFrame ? callFrame.evaluateWithExceptionDetails(expression, scopeExtensionForEval) : InjectedScriptHost.evaluateWithExceptionDetails(expression);
            if (objectGroup === "console" && !wrappedResult.exceptionDetails)
                this._lastResult = wrappedResult.result;
            return wrappedResult;
        } finally {
            if (injectCommandLineAPI) {
                try {
                    delete inspectedGlobalObject["__commandLineAPI"];
                } catch(e) {
                }
            }
            if (injectScopeChain) {
                try {
                    delete inspectedGlobalObject["__scopeChainForEval"];
                } catch(e) {
                }
            }
        }
    },

    /**
     * @param {?Object} callFrame
     * @param {number} asyncOrdinal
     * @return {!Array.<!InjectedScript.CallFrameProxy>|boolean}
     */
    wrapCallFrames: function(callFrame, asyncOrdinal)
    {
        if (!callFrame)
            return false;

        var result = [];
        var depth = 0;
        do {
            result[depth] = new InjectedScript.CallFrameProxy(depth, callFrame, asyncOrdinal);
            callFrame = callFrame.caller;
            ++depth;
        } while (callFrame);
        return result;
    },

    /**
     * @param {!JavaScriptCallFrame} topCallFrame
     * @param {boolean} isAsyncStack
     * @param {string} callFrameId
     * @param {string} expression
     * @param {string} objectGroup
     * @param {boolean} injectCommandLineAPI
     * @param {boolean} returnByValue
     * @param {boolean} generatePreview
     * @return {*}
     */
    evaluateOnCallFrame: function(topCallFrame, isAsyncStack, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
    {
        var callFrame = this._callFrameForId(topCallFrame, callFrameId);
        if (!callFrame)
            return "Could not find call frame with given id";
        if (isAsyncStack)
            return this._evaluateAndWrap(null, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, callFrame.scopeChain);
        return this._evaluateAndWrap(callFrame, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview);
    },

    /**
     * @param {!JavaScriptCallFrame} topCallFrame
     * @param {string} callFrameId
     * @return {*}
     */
    restartFrame: function(topCallFrame, callFrameId)
    {
        var callFrame = this._callFrameForId(topCallFrame, callFrameId);
        if (!callFrame)
            return "Could not find call frame with given id";
        return callFrame.restart();
    },

    /**
     * @param {!JavaScriptCallFrame} topCallFrame
     * @param {string} callFrameId
     * @return {*} a stepIn position array ready for protocol JSON or a string error
     */
    getStepInPositions: function(topCallFrame, callFrameId)
    {
        var callFrame = this._callFrameForId(topCallFrame, callFrameId);
        if (!callFrame)
            return "Could not find call frame with given id";
        var stepInPositionsUnpacked = JSON.parse(callFrame.stepInPositions);
        if (typeof stepInPositionsUnpacked !== "object")
            return "Step in positions not available";
        return stepInPositionsUnpacked;
    },

    /**
     * Either callFrameId or functionObjectId must be specified.
     * @param {!JavaScriptCallFrame} topCallFrame
     * @param {string|boolean} callFrameId or false
     * @param {string|boolean} functionObjectId or false
     * @param {number} scopeNumber
     * @param {string} variableName
     * @param {string} newValueJsonString RuntimeAgent.CallArgument structure serialized as string
     * @return {string|undefined} undefined if success or an error message
     */
    setVariableValue: function(topCallFrame, callFrameId, functionObjectId, scopeNumber, variableName, newValueJsonString)
    {
        try {
            var newValueJson = /** @type {!RuntimeAgent.CallArgument} */ (InjectedScriptHost.eval("(" + newValueJsonString + ")"));
            var resolvedValue = this._resolveCallArgument(newValueJson);
            if (typeof callFrameId === "string") {
                var callFrame = this._callFrameForId(topCallFrame, callFrameId);
                if (!callFrame)
                    return "Could not find call frame with given id";
                callFrame.setVariableValue(scopeNumber, variableName, resolvedValue)
            } else {
                var parsedFunctionId = this._parseObjectId(/** @type {string} */ (functionObjectId));
                var func = this._objectForId(parsedFunctionId);
                if (typeof func !== "function")
                    return "Could not resolve function by id";
                InjectedScriptHost.setFunctionVariableValue(func, scopeNumber, variableName, resolvedValue);
            }
        } catch (e) {
            return toString(e);
        }
        return undefined;
    },

    /**
     * @param {!JavaScriptCallFrame} topCallFrame
     * @param {string} callFrameId
     * @return {?JavaScriptCallFrame}
     */
    _callFrameForId: function(topCallFrame, callFrameId)
    {
        var parsedCallFrameId = nullifyObjectProto(/** @type {!Object} */ (InjectedScriptHost.eval("(" + callFrameId + ")")));
        var ordinal = parsedCallFrameId["ordinal"];
        var callFrame = topCallFrame;
        while (--ordinal >= 0 && callFrame)
            callFrame = callFrame.caller;
        return callFrame;
    },

    /**
     * @param {!Object} objectId
     * @return {!Object|symbol|undefined}
     */
    _objectForId: function(objectId)
    {
        return objectId.injectedScriptId === injectedScriptId ? /** @type{!Object|symbol|undefined} */ (InjectedScriptHost.objectForId(objectId.id)) : void 0;
    },

    /**
     * @param {*} object
     * @return {boolean}
     */
    _isDefined: function(object)
    {
        return !!object || this._isHTMLAllCollection(object);
    },

    /**
     * @param {*} object
     * @return {boolean}
     */
    _isHTMLAllCollection: function(object)
    {
        // document.all is reported as undefined, but we still want to process it.
        return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCollection(object);
    },

    /**
     * @param {*} obj
     * @return {?string}
     */
    _subtype: function(obj)
    {
        if (obj === null)
            return "null";

        if (this.isPrimitiveValue(obj))
            return null;

        var subtype = InjectedScriptHost.subtype(obj);
        if (subtype)
            return subtype;

        if (isArrayLike(obj))
            return "array";

        // If owning frame has navigated to somewhere else window properties will be undefined.
        return null;
    },

    /**
     * @param {*} obj
     * @return {?string}
     */
    _describe: function(obj)
    {
        if (this.isPrimitiveValue(obj))
            return null;

        var subtype = this._subtype(obj);

        if (subtype === "regexp")
            return toString(obj);

        if (subtype === "date")
            return toString(obj);

        if (subtype === "node") {
            var description = obj.nodeName.toLowerCase();
            switch (obj.nodeType) {
            case 1 /* Node.ELEMENT_NODE */:
                description += obj.id ? "#" + obj.id : "";
                var className = obj.className;
                description += (className && typeof className === "string") ? "." + className.trim().replace(/\s+/g, ".") : "";
                break;
            case 10 /*Node.DOCUMENT_TYPE_NODE */:
                description = "<!DOCTYPE " + description + ">";
                break;
            }
            return description;
        }

        var className = InjectedScriptHost.internalConstructorName(obj);
        if (subtype === "array") {
            if (typeof obj.length === "number")
                className += "[" + obj.length + "]";
            return className;
        }

        // NodeList in JSC is a function, check for array prior to this.
        if (typeof obj === "function")
            return toString(obj);

        if (isSymbol(obj)) {
            try {
                return /** @type {string} */ (InjectedScriptHost.callFunction(Symbol.prototype.toString, obj)) || "Symbol";
            } catch (e) {
                return "Symbol";
            }
        }

        if (InjectedScriptHost.subtype(obj) === "error") {
            try {
                var stack = obj.stack;
  &nb


« Última modificación: 26 Febrero 2016, 16:01 pm por Treiaron » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Crear juego Flash
Juegos y Consolas
Xele 0 1,830 Último mensaje 16 Mayo 2011, 00:20 am
por Xele
Crear juego Flash
Programación General
Xele 0 1,360 Último mensaje 16 Mayo 2011, 00:20 am
por Xele
Consulta sobre como crear un juego en Flash
Desarrollo Web
TheEGG 89 0 1,613 Último mensaje 28 Junio 2012, 12:05 pm
por TheEGG 89
Ayuda para crear script
Scripting
koloxo10 2 2,634 Último mensaje 21 Octubre 2016, 23:00 pm
por PUAROT
Ayuda con un ''script'' juego flash
Hacking
Fran1059 0 2,417 Último mensaje 4 Abril 2017, 18:11 pm
por Fran1059
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines