Pseudo Browser with Google Spreadsheet

Gist

Overview

This is a sample script for creating the pseudo browser using Google Spreadsheet.

Description

I unexpectedly noticed this. I think that this is for off-line browsing using HTML data. So there are many limitations. At first, please confirm them.

What I thought the interesting is that the appearance of the site has been maintained at this pseudo browser. And, by using this, the sites which are slow speed at your environment might be able to be opened smoothly.

Demo

Pseudo Browser with Google Spreadsheet

Script

Please copy and paste following respective HTML and GAS to your script editor. Please launch the script editor on container-bound script for spreadsheet.

1. HTML

Filename is index.html.

<!DOCTYPE html>
<html>
  <head>
    <style>
      input.in1 {
        width: 90%;
      }
    </style>
  </head>
  <body>
    <form>
      <input type="text" name="url" class="in1">
      <input type="button" value="Run" class="in2"
        onclick="
        google.script.run
        .withSuccessHandler(google.script.host.close)
        .launchbrowser(this.parentNode)
      ">
    </form>
  </body>
</html>

2. GAS

Filename is code.gs.

function inputurl() {
  var html = HtmlService.createHtmlOutputFromFile('index')
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .setWidth(600)
    .setHeight(80);
  SpreadsheetApp.getUi().showModalDialog(html, 'URL?');
}

function launchbrowser(p) {
  var html = UrlFetchApp.fetch(p.url);
  var blob = HtmlService.createHtmlOutput(html)
    .setWidth(800)
    .setHeight(500)
    .setTitle("Sample Browser");
  SpreadsheetApp.getActiveSpreadsheet().show(blob);
}

 Share!