Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for missing Google and YouTube Apps #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/migrated_app_icons/docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/migrated_app_icons/drive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/migrated_app_icons/gmail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/migrated_app_icons/sheets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/migrated_app_icons/slides.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/migrated_app_icons/youtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';
var app = angular.module('newTab', ['newTab.controllers', 'newTab.directives', 'newTab.filters']);

app.constant('IMAGE_SOURCES', /^\s*(https?|ftp|file|blob|chrome):|data:image\//);
app.constant('IMAGE_SOURCES', /^\s*(https?|ftp|file|blob|chrome|chrome-extension):|data:image\//);
app.constant('ANCHOR_HREFS', /^\s*(https?|ftp|mailto|tel|file|chrome|about|chrome-extension):/);
app.constant('ANCHOR_HREFS_REQ_UPDATE', /^\s*(file|chrome|chrome-extension):/);

Expand Down
23 changes: 23 additions & 0 deletions js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,32 @@
$scope.apps = results.filter(function (result) {
return (/^(extension|theme)$/).test(result.type) === false;
});
}).then(async function() {
$scope.apps.push(...await getMigratedApps())
});
}

async function getMigratedApps() {
const basePath = "../migrated_apps/";
const jsonPaths = ["slides.json", "docs.json", "drive.json", "youtube.json", "sheets.json", "gmail.json"];
let migratedApps = [];

for (const path of jsonPaths) {
const i = jsonPaths.indexOf(path);
let url = basePath + path;
await fetch(url)
.then(res => res.json())
.then(function(data) {
migratedApps.push(data);
})
.catch((error) => {
console.error(error);
})
}

return migratedApps;
}

$scope.$on('UninstalledApp', loadApps);

// initial page setup
Expand Down
3 changes: 3 additions & 0 deletions js/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
append = '?grayscale=true';
}

// Replace $CHROME_EXT_ID$ with extensionID if it exists.
found.url = found.url.replace("$CHROME_EXT_ID$", chrome.runtime.id);

return found.url + append;
}
return void 0;
Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "New Tab Redirect",
"short_name": "NTR!",
"description": "Allows a user to provide the URL of the page that loads in a new tab.",
"version": "3.1.5",
"version": "3.1.6",
"background": {
"scripts" : ["js/background.js"],
"persistent": false
Expand All @@ -20,5 +20,6 @@
"19":"images/icon19.png"
},
"incognito": "split",
"minimum_chrome_version" : "22"
"minimum_chrome_version" : "22",
"web_accessible_resources": ["images/migrated_app_icons/*.png"]
}
29 changes: 29 additions & 0 deletions migrated_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
At some point Google decided to migrate some of their apps from the chrome webstore to their new G-Suite.

This meant that the "default" Google and YouTube apps were no longer getting returned by the API.

As of the current time of writing this the only non-code-change workaround for this problem is to disable the following chrome flags:

``#enable-migrate-default-chrome-app-to-web-apps-gsuite``

``#enable-migrate-default-chrome-app-to-web-apps-non-gsuite``

Going under the assumption that Google will eventually remove these flags I have made the following workaround:

1. Copied the API responses for all the 6 now missing Apps, and put them in the ``migrated_apps`` directory.

2. Downloaded the icons for all 6 Apps and put them in the ``images/migrated_app_icons`` directory.

3. Modified the icon url with a regex substring that will be replaced with extension id.

4. Concatenated the app list in loadApps with the migrated apps


Pros of this workaround:

1. It Works.

Cons of this workaround:

1. It involves keeping snapshots of these App API responses
2. Some features like "Uninstall" will be rendered useless on these specific migrated apps
28 changes: 28 additions & 0 deletions migrated_apps/docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"appLaunchUrl": "chrome-extension://aohghmighlieiainnegkcijnfilokake/main.html",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "Create and edit documents ",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/aohghmighlieiainnegkcijnfilokake",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/docs.png"
}
],
"id": "aohghmighlieiainnegkcijnfilokake",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": true,
"name": "Docs",
"offlineEnabled": true,
"optionsUrl": "",
"permissions": [],
"shortName": "Docs",
"type": "legacy_packaged_app"
}
32 changes: 32 additions & 0 deletions migrated_apps/drive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"appLaunchUrl": "https://drive.google.com/?usp=chrome_app",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "Google Drive: create, share and keep all your stuff in one place.",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/apdfllckaahabafndbhieahigkjlhalf",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/drive.png"
}
],
"id": "apdfllckaahabafndbhieahigkjlhalf",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": true,
"name": "Google Drive",
"offlineEnabled": true,
"optionsUrl": "https://drive.google.com/drive/settings",
"permissions": [
"clipboardRead",
"clipboardWrite",
"notifications"
],
"shortName": "Google Drive",
"type": "hosted_app"
}
30 changes: 30 additions & 0 deletions migrated_apps/gmail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"appLaunchUrl": "https://mail.google.com/mail",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "Fast, searchable email with less spam.",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/pjkljhegncpnkpknbcohdijeoejaedia",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/gmail.png"
}
],
"id": "pjkljhegncpnkpknbcohdijeoejaedia",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": true,
"name": "Gmail",
"offlineEnabled": false,
"optionsUrl": "https://mail.google.com/mail/#settings",
"permissions": [
"notifications"
],
"shortName": "Gmail",
"type": "hosted_app"
}
28 changes: 28 additions & 0 deletions migrated_apps/sheets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"appLaunchUrl": "chrome-extension://felcaaldnbdncclmgdcncolpebgiejap/main.html",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "Create and edit spreadsheets",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/felcaaldnbdncclmgdcncolpebgiejap",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/sheets.png"
}
],
"id": "felcaaldnbdncclmgdcncolpebgiejap",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": true,
"name": "Sheets",
"offlineEnabled": true,
"optionsUrl": "",
"permissions": [],
"shortName": "Sheets",
"type": "legacy_packaged_app"
}
28 changes: 28 additions & 0 deletions migrated_apps/slides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"appLaunchUrl": "chrome-extension://aapocclcgogkmnckokdopfmhonfmgoek/main.html",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "Create and edit presentations ",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/aapocclcgogkmnckokdopfmhonfmgoek",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/slides.png"
}
],
"id": "aapocclcgogkmnckokdopfmhonfmgoek",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": false,
"name": "Slides",
"offlineEnabled": true,
"optionsUrl": "",
"permissions": [],
"shortName": "Slides",
"type": "legacy_packaged_app"
}
28 changes: 28 additions & 0 deletions migrated_apps/youtube.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"appLaunchUrl": "http://www.youtube.com/",
"availableLaunchTypes": [
"OPEN_AS_REGULAR_TAB",
"OPEN_AS_WINDOW"
],
"description": "",
"enabled": true,
"homepageUrl": "https://chrome.google.com/webstore/detail/blpcfgokakmgnkcojhhkbfbldkacnbeo",
"hostPermissions": [],
"icons": [
{
"size": 128,
"url": "chrome-extension://$CHROME_EXT_ID$/images/migrated_app_icons/youtube.png"
}
],
"id": "blpcfgokakmgnkcojhhkbfbldkacnbeo",
"installType": "normal",
"isApp": true,
"launchType": "OPEN_AS_REGULAR_TAB",
"mayDisable": true,
"name": "YouTube",
"offlineEnabled": false,
"optionsUrl": "",
"permissions": [],
"shortName": "YouTube",
"type": "hosted_app"
}