Updating custom scripts. TBMS version.

    As I wrote in the introductory article about GreaseMonkey, dissatisfied with the lack of an update system for custom scripts, we took the issue into development. A few days later, the solution materialized into a complex tool, which we called the “Script Template Generator for GreaseMonkey”. Its interface is available at tbms.ru/greasemonkey/generator.

    The generator creates a user-defined script that contains , in addition to all the necessary meta- information , the GMHelper object , which implements the update system and several other useful functions.



    The main function of GMHelperis a script update. All the functionality is already built into the template, the only thing you need to do is to indicate a valid link to the location of the JS file with the script (via the generator) and follow the version numbering during development. Once every 24 hours, GMHelper downloads the first kilobyte from the JS file by the link and looks to see if the version has changed there, in case of a change it suggests downloading. If you refuse, it leaves you alone for another 24 hours.

    During the development of GMHelper appeared a few more useful, in our opinion, functions. First, we wrapped GM_getValue / GM_setValue in GMHelper shells.getValue / setValue. This solves two problems: checking for GM availability (if you are doing a cross-browser script) and converting unsupported types when writing (trying to write Date via GM_setValue causes an error).

    Well, for the sake of order, we placed the getNamespace JS namespaces generator, which takes the desired window as a parameter (hello unsafeWindow), and an array of names for nested namespaces. Let's look at an example: create the WebSphere Namespace.InlinePlayer at window GreaseMonkey. In conclusion, I want to say that we will be glad to any comments and suggestions and, in turn, we hope that our template will be useful.

    GMHelper.getNamespace(window, ['Weborama', 'InlinePlayer']);





    Also popular now: