TamperMonkey Script to Edit 3Q&S Formulas

  • 1.  TamperMonkey Script to Edit 3Q&S Formulas

    Posted 12-21-2018 15:39
    If you have tried to use the 3Q&S Technique to build self-contained Rich Text Formula Fields with inline script you may have noticed that when re-editing the formula some white-space characters are modified.

    For instance if you used this formula definition:
    "<img src onerror='

    (async () => {

      $('#bodyTable').css('background-color', 'yellow');
      $('table.LabelsLeft tr > td.cell,
         table.LabelsLeft tr > td.label,
         div.Email table.LabelsLeft tr td.cell,
         div.Email table.LabelsLeft tr td.label').css('border', 'solid yellow');

    After saving and re-editing the formula you are presented with this formula definition:
    "<img src onerror='\n\n(async () => {\n  $('#bodyTable').css('background-color', 'yellow');\n\n  $('table.LabelsLeft tr > td.cell,\n     table.LabelsLeft tr > td.label,\n     div.Email table.LabelsLeft tr td.cell,\n     div.Email table.LabelsLeft tr td.label').css('border', 'solid yellow');\n\n})();\n\n'>"
    This is simply due to QuickBase "cleaning up" what it thinks is a conventional formula. You can automatically restore the original formula you entered by using a TamperMonkey script. TamperMonkey scripts are the most recent version of what has been previously called GreaseMonkey scripts or in general Userscripts. Userscripts are loaded into your browser through an extension and they execute whenever a page matching a URL pattern is loaded. It is a simple way to "enhance" the behavior of any web page and they can be quick life-savers to make a web page (or QuickBase) appear or behave they way you want - not the way the original author of the page wants.

    Here is a screenshot of the above formula editing session after my TamperMonkey script kicks in and does its thing:

    TamperMonkey for Chrome can be downloaded here:

    Tampermonkey Extension for Chrome

    Pastie Database


    (1) The user script in the Pastie operates by removing the ACE editor and displaying the actual textarea associated with the formula being edited (ie <textarea id=frexp>. Next it performs a simple regexp replacement to correct the white-space so the formula can be edited as it was originally entered by the user.

    (2) I have many other TamperMonkey scripts that manipulate the formula editor and other aspects of the QuickBase interface some of which I will share as 2019 rolls along. TamperMonkey can be used to set defaults on administrative pages, splice in new functionality or integrate with other tools.

    (3) Although I have not test my Userscript with other browsers, TamperMonkey is supported by a variety of browsers:

    TamperMonkey Homepage
    Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.