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

Offline docs extension #130

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

191 changes: 35 additions & 156 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 25 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { BrowserWindow, ipcMain, nativeTheme, app } = require("electron");
const { BrowserWindow, ipcMain, nativeTheme, app, session } = require("electron");
require("@electron/remote/main").initialize();

const store = require("./src/helpers/store");
const config = require("./src/helpers/config");
Expand All @@ -8,6 +9,9 @@ const {
} = require("./src/helpers/util");

const { createMainWindow } = require("./src/js/mainwindow");
const path = require("path");
const {userAgent, signInURL} = require("./src/helpers/config");
const isPackaged = require('electron-is-packaged').isPackaged;

// Listen for theme requests from windows to set theme
ipcMain.on("theme-request", function (_, webContentsId) {
Expand All @@ -31,8 +35,25 @@ const unsubscribeStoreWatch = store.onDidChange(USER_PREF_KEYS.THEME, () => {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createMainWindow();
app.whenReady().then(async () => {

// Assumes that you put the unpacked extension in the project folder and called the folder "offline"
let appPackagedPath = "offline";
let offlineToolsPath = path.join(path.resolve("."), appPackagedPath);;
if (isPackaged){
appPackagedPath = `${config.osPlatform === OS_PLATFORMS.MAC_OS ? ".." : "."}/offline`;
offlineToolsPath = path.join(path.dirname(process.execPath), appPackagedPath);
}
await session.defaultSession.loadExtension(offlineToolsPath).then(() => createMainWindow()).catch((e) => console.error(e));
// Check the urls and pass the weird User-Agent to let google sign you in.
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
if (details.url.includes("accounts.google")){
details.requestHeaders['User-Agent'] = "Chrome";
} else {
details.requestHeaders['User-Agent'] = userAgent;
}
callback({ cancel: false, requestHeaders: details.requestHeaders });
});

app.on("activate", function () {
// On macOS it's common to re-create a window in the app when the
Expand All @@ -45,7 +66,7 @@ app.whenReady().then(() => {
app.on("window-all-closed", function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (config.osPlatform !== OS_PLATFORMS.MAC_OS) app.quit();
if (config.osPlatform === OS_PLATFORMS.MAC_OS) app.quit();

unsubscribeStoreWatch();
});
Expand Down
Binary file added offline/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions offline/_locales/af/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"createnew":{"message":"SKEP NUWE"},"explanationofflinedisabled":{"message":"Jy is vanlyn. As jy Google Dokumente sonder 'n internetverbinding wil gebruik, moet jy die volgende keer as jy aan die internet gekoppel is na instellings op die Google Dokumente-tuisblad gaan en vanlynsinkronisering aanskakel."},"explanationofflineenabled":{"message":"Jy is vanlyn, maar jy kan nog steeds beskikbare l\u00eaers redigeer of nuwes skep."},"extdesc":{"message":"Skep, wysig en bekyk jou dokumente, sigblaaie en aanbiedings \u2013 alles sonder toegang tot die internet."},"extname":{"message":"Google Vanlyn Dokumente"},"learnmore":{"message":"Kom meer te wete"},"popuphelptext":{"message":"Skryf, redigeer en werk saam, waar jy ook al is, met of sonder 'n internetverbinding."}}
23 changes: 23 additions & 0 deletions offline/_locales/am/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"createnew": {
"message": "አዲስ ፍጠር"
},
"explanationofflinedisabled": {
"message": "ከመስመር ውጪ ነዎት። Google ሰነዶችን ያለበይነመረብ ግንኙነት ለመጠቀም በGoogle ሰነዶች መነሻ ገጽ ላይ ወደ ቅንብሮች ይሂዱና ከበይነመረቡ ጋር በሚገናኙበት ቀጣዩ ጊዜ ላይ የመስመር ውጭ ስምረትን ያብሩ።"
},
"explanationofflineenabled": {
"message": "ከመስመር ውጪ ነዎት፣ ነገር ግን አሁንም የሚገኙ ፋይሎችን ማርትዕ ወይም አዲሶችን መፍጠር ይችላሉ።"
},
"extdesc": {
"message": "የእርስዎን ሰነዶች፣ የተመን ሉሆች እና የዝግጅት አቀራረቦች ያርትዑ፣ ይፍጠሩ እና ይመልከቱ — ሁሉንም ያለ በይነመረብ መዳረሻ።"
},
"extname": {
"message": "ከመስመር ውጪ Google ሰነዶች"
},
"learnmore": {
"message": "ተጨማሪ ለመረዳት"
},
"popuphelptext": {
"message": "የትም ይሁኑ በበይነመረብ ግንኙነት ወይም ያለእሱ ይጻፉ፣ ያርትዑ እና ይተባበሩ።"
}
}
23 changes: 23 additions & 0 deletions offline/_locales/ar/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"createnew": {
"message": "إنشاء جديد"
},
"explanationofflinedisabled": {
"message": "أنت بلا اتصال، لاستخدام مستندات Google بلا اتصال بالإنترنت، انتقل إلى الإعدادات في الصفحة الرئيسية لمستندات Google وشغّل المزامنة بلا اتصال في المرة القادمة التي تتصل فيها بالإنترنت."
},
"explanationofflineenabled": {
"message": "أنت بلا اتصال، ولكن لا يزال بإمكانك تعديل الملفات المتاحة أو إنشاء ملفات جديدة."
},
"extdesc": {
"message": "تعديل المستندات وجداول البيانات والعروض التقديمية وإنشاؤها وعرضها، كل ذلك بلا اتصال بالإنترنت"
},
"extname": {
"message": "مستندات Google بلا إنترنت"
},
"learnmore": {
"message": "المزيد من المعلومات"
},
"popuphelptext": {
"message": "يمكنك الكتابة والتعديل والتعاون من أي مكان، سواء كنت متصلاً بالإنترنت أو لا."
}
}
23 changes: 23 additions & 0 deletions offline/_locales/az/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"createnew": {
"message": "YENİSİNİ YARADIN"
},
"explanationofflinedisabled": {
"message": "Oflaynsınız. Google Sənədi internet bağlantısı olmadan istifadə etmək istəyirsinizsə, Google Sənədin əsas səhifəsində ayarlara gedin və növbəti dəfə internetə qoşulanda oflayn sinxronizasiyanı aktiv edin."
},
"explanationofflineenabled": {
"message": "Oflaynsınız, amma mövcud faylları redaktə edə və yenilərini yarada bilərsiniz."
},
"extdesc": {
"message": "Sənəd, cədvəl və təqdimatların hamısını internet olmadan redaktə edin, yaradın və baxın."
},
"extname": {
"message": "Google Sənəd Oflayn"
},
"learnmore": {
"message": "Ətraflı Məlumat"
},
"popuphelptext": {
"message": "Harda olmağınızdan və internetə qoşulu olub-olmadığınızdan asılı olmayaraq, yazın, redaktə edin və əməkdaşlıq edin."
}
}
Loading