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

Manifest V3 Support #160

Open
wants to merge 3 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
37 changes: 1 addition & 36 deletions content/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -445,39 +445,4 @@ <h2 class="VfPpkd-k2Wrsb">Create Branch</h2>
</div>
<div class="VfPpkd-IE5DDf"></div>
<div tabindex="0" class="pw1uU"></div>
</div>

<!--
<div id="branch-modal" class="modal-dialog" tabindex="0" role="dialog" style="left: 274px; top: 280px; display: none;">
<div class="modal-dialog-title modal-dialog-title-draggable">
<span class="modal-dialog-title-text">Create Branch</span>
<span class="scm-branch-modal-close modal-dialog-title-close"></span>
</div>
<div class="modal-dialog-content">
<div class="goog-inline-block" style="width: 600px; height: 90px;">
<div class="scm-branch">
<table class="properties-data-dialog-table">
<tbody>
<tr class="properties-data-dialog-table-header">
<th>Properties</th>
<th>Value</th>
<th></th>
</tr>
<tr class="properties-data-dialog-table-row">
<td>
<div>Branch Name</div>
</td>
<td><input id="new-branch-name" class="editable-row-input large-input" type="text"
placeholder="new-branch-name"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="scm-modal-button modal-dialog-buttons">
<button id="scm-create-branch" type="button" class="goog-buttonset-default goog-buttonset-action"
disabled="true">Create</button>
<button type="button" class="scm-branch-modal-close">Cancel</button>
</div>
</div> -->
</div>
37 changes: 23 additions & 14 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "5.0.5",
"manifest_version": 2,
"version": "5.1.0.0",
"manifest_version": 3,
"default_locale": "en",
"name": "__MSG_appName__",
"short_name": "gas-github",
Expand All @@ -12,9 +12,7 @@
"128": "icon/icon.png"
},
"background": {
"scripts": [
"background/background.js"
]
"service_worker": "background/background.js"
},
"options_ui": {
"page": "options/options.html"
Expand Down Expand Up @@ -43,23 +41,34 @@
"run_at": "document_end"
}
],
"content_security_policy":"script-src 'self' https://apis.google.com; object-src 'self'",
"content_security_policy": {
"extension_pages":"script-src 'self'; object-src 'self'"
},
"web_accessible_resources": [
"gas-hub.js",
"options/options.html",
"content/alert.html",
"content/button.html",
"content/modal.html",
"content/login.html"
{
"resources": [
"src/gas-hub.js",
"options/options.html",
"content/alert.html",
"content/button.html",
"content/modal.html",
"content/login.html"
],
"matches": [
"https://script.google.com/*"
]
}
],
"permissions": [
"https://script.google.com/*",
"identity",
"storage"
],
"host_permissions": [
"https://script.google.com/*"
],
"oauth2": {
"client_id": "971735641612-plgfavrj0vhpsd1brvquo4qt7m91ujs6.apps.googleusercontent.com",
"scopes":["https://www.googleapis.com/auth/script.projects"]
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApkXU5iUw1bq/mTyz8lR4l8jSgZgLAc6udwsO+FpdsisNrpCzy3EyDB52eibE+s+6IycE5G3XEkMMhtZfGOPe0BK3qz7DML1XQ2Q3GChe7rsRbWrQckzYMRwsoS6ogSJGEFccbWpzofKV1lZlc0Tu0SXVglF71b3gioPBU4K4ym1X44axuTeAjak9fqB7ICM8OkvxetenDXE+UN0zv+Y2SY+FdlY2Q2+QD5SDJ1PhydDXn7kAGiIYVzUbVWvmKyT0briT5niBbF+lMqmYeDMRCtzlcdI7ym0WGihx0ckDZJcmDksSMgEpNyzlGaYjx08+UHQ2O7a5nqUcUfUUg6307QIDAQAB"
}
}
2 changes: 1 addition & 1 deletion options/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

.form .message,
.form .warning {
margin: 15px 0 0;
margin: 15px;
color: #b3b3b3;
font-size: 14px;
}
Expand Down
34 changes: 7 additions & 27 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h2>Logged in as: <a target="_blank" id="login-user">XXX</a></h2>
<p class="message">Please make sure you have enabled <a target="_blank" href="https://script.google.com/home/usersettings">Script API</a></p>
<button id="logout">logout</button>
<p class="warning">After logout, remember to delete the <a id="token" href="#">access token</a></p>
<p class="warning">After logout, remember to delete the <a target="_blank" id="token" href="#">access token</a></p>
</div>
<div class="login-container github-login-container">
<div class="login-item login-item-basic">
Expand All @@ -23,11 +23,6 @@ <h2>Logged in as: <a target="_blank" id="login-user">XXX</a></h2>
<b>repo</b> and <b>gist</b>
scope):</p>
<input id="accesstoken" type="password" placeholder="github access token" />
<!-- <p class="label"><a target="_blank"
href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=971735641612-am059p55sofdp30p2t4djecn72l6kmpf.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/script.projects&access_type=offline">
Grant Google oauth token</a> (paste the result code here)
<br>*or leave it empty to use Chrome login user(for <b>Chrome</b> only)</p>
<input id="api-key" type="password" placeholder="google oauth token" /> -->
</div>
<div class="login-item login-item-otp">
<input id="otp" type="text" placeholder="authentication code">
Expand All @@ -46,17 +41,12 @@ <h2>Logged in as: <a target="_blank" id="login-user">XXX</a></h2>
<input id="ghe-password" type="password" placeholder="password" />
<p class="label">or accessToken(with <b>repo</b> and <b>gist</b> scope):</p>
<input id="ghe-accesstoken" type="password" placeholder="access token" />
<!-- <p class="label"><a target="_blank"
href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=971735641612-am059p55sofdp30p2t4djecn72l6kmpf.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/script.projects&access_type=offline">
Grant Google oauth key</a> (paste the result code here)
<br>*or leave it empty to use Chrome login user(for <b>Chrome</b> only)</p>
<input id="ghe-api-key" type="password" placeholder="google oauth token" /> -->
</div>
<div class="login-item login-item-otp">
<input id="ghe-otp" type="text" placeholder="authentication code">
</div>
<button id="ghe-login">github enterprise login</button>
<p class="message">Please star this extension on <a href="https://github.com/leonhartX/gas-github">Github</a>
<p class="message">Please star this extension on <a target="_blank" href="https://github.com/leonhartX/gas-github">Github</a>
for support</p>
<p class="message">Switch to <a name="github" href="#">Github</a>, <a name="bitbucket" href="#">Bitbucket</a> or
<a name="gitlab" href="#">GitLab</a></p>
Expand All @@ -68,35 +58,25 @@ <h2>Logged in as: <a target="_blank" id="login-user">XXX</a></h2>
<div class="login-item login-item-basic">
<input id="bitbucket-email" type="email" placeholder="email" />
<input id="bitbucket-password" type="password" placeholder="password" />
<!-- <p class="label"><a target="_blank"
href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=971735641612-am059p55sofdp30p2t4djecn72l6kmpf.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/script.projects&access_type=offline">
Grant Google oauth token</a> (paste the result code here)
<br>*or leave it empty to use Chrome login user(for <b>Chrome</b> only)</p>
<input id="bitbucket-api-key" type="password" placeholder="google oauth token" /> -->
</div>
<button id="bitbucket-login">bitbucket login</button>
<p class="message">Please star this extension on <a href="https://github.com/leonhartX/gas-github">Github</a>
<p class="message">Please star this extension on <a target="_blank" href="https://github.com/leonhartX/gas-github">Github</a>
for support</p>
<p class="message">Switch to <a name="github" href="#">Github</a>, <a name="ghe" href="#">Github Enterprise</a>
or <a name="gitlab" href="#">GitLab</a></p>
<p class="error" style="display: none">Can not login, please check your username and password.</p>
</div>
<div class="login-container gitlab-login-container">
<div class="login-item login-item-basic">
<input id="gitlab-url" type="text" value="https://gitlab.com"/>
<input id="gitlab-url" type="text" placeholder="gitlab url"/>
<input id="gitlab-email" type="email" placeholder="email" />
<p class="label">login with password:</p>
<input id="gitlab-password" type="password" placeholder="password" />
<p class="label">or personal accessToken(with <b>api</b> scope):</p>
<p class="label">or Personal Access Token (with <b>api</b> scope) if self-hosted:</p>
<input id="gitlab-accesstoken" type="password" placeholder="access token" />
<!-- <p class="label"><a target="_blank"
href="https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=971735641612-am059p55sofdp30p2t4djecn72l6kmpf.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/script.projects&access_type=offline">
Grant Google oauth token</a> (paste the result code here)
<br>*or leave it empty to use Chrome login user(for <b>Chrome</b> only)</p>
<input id="gitlab-api-key" type="password" placeholder="google oauth token" /> -->
</div>
<button id="gitlab-login">gitlab login</button>
<p class="message">Please star this extension on <a href="https://github.com/leonhartX/gas-github">Github</a>
<p class="message">Please star this extension on <a target="_blank" href="https://github.com/leonhartX/gas-github">Github</a>
for support</p>
<p class="message">Switch to <a name="github" href="#">Github</a>, <a name="ghe" href="#">Github Enterprise</a>
or <a name="bitbucket" href="#">Bitbucket</a></p>
Expand All @@ -105,4 +85,4 @@ <h2>Logged in as: <a target="_blank" id="login-user">XXX</a></h2>
</div>
</body>

</html>
</html>
54 changes: 6 additions & 48 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ $(() => {
} else {
domain = `@${match[1].match(/\w+\.\w+(?=\/|$)/)}`;
userLink = `https://${match[1]}/${user}`;
tokenLink = `https://${match[1]}/profile/personal_access_tokens`;
tokenLink = `https://${match[1]}/-/profile/personal_access_tokens`;
}
} else {
domain = '@gitlab.com';
userLink = `https://gitlab.com/${user}`;
tokenLink = `https://gitlab.com/profile/personal_access_tokens`;
tokenLink = `https://gitlab.com/profile/-/personal_access_tokens`;
}
} else {
domain = '@Github.com';
Expand All @@ -74,7 +74,7 @@ $(() => {
}
}

$('#login-user').text(`${user}${domain}`).attr('href', userLink);
$('#login-user').text(`${user}`).attr('href', userLink);
$('#token').attr('href', tokenLink);
})
.then(() => {
Expand All @@ -89,15 +89,12 @@ function getGithubParam() {
const scm = 'github';
const username = $('#username').val();
const token = $('#accesstoken').val();
// const apiKey = $('#api-key').val();
const apiKey = null;
const baseUrl = `https://api.github.com`;
const otp = $('#otp').val();
return {
scm,
username,
token,
apiKey,
baseUrl,
otp
};
Expand All @@ -108,16 +105,13 @@ function getGHEParam() {
const username = $('#ghe-username').val();
const password = $('#ghe-password').val();
const token = $('#ghe-accesstoken').val();
// const apiKey = $('#ghe-api-key').val();
const apiKey = null;
const baseUrl = $('#ghe-url').val() + '/api/v3';
const otp = $('#ghe-otp').val();
return {
scm,
username,
password,
token,
apiKey,
baseUrl,
otp
};
Expand All @@ -127,14 +121,11 @@ function getBitbucketParam() {
const scm = 'bitbucket';
const username = $('#bitbucket-email').val();
const password = $('#bitbucket-password').val();
// const apiKey = $('#bitbucket-api-key').val();
const apiKey = null;
const baseUrl = `https://api.bitbucket.org/2.0`;
return {
scm,
username,
password,
apiKey,
baseUrl
}
}
Expand All @@ -145,16 +136,13 @@ function getGitLabParam() {
const password = $('#gitlab-password').val();
const token = $('#gitlab-accesstoken').val();
const tokenType = (token && token.length > 0) ? 'personalToken' : 'oAuth';
// const apiKey = $('#gitlab-api-key').val();
const apiKey = null;
const baseUrl = ($('#gitlab-url').val() || 'https://gitlab.com') + '/api/v4';
return {
scm,
username,
password,
tokenType,
token,
apiKey,
baseUrl
}
}
Expand All @@ -166,35 +154,7 @@ function addCred(param) {
if (param.password === '' && param.token === '') {
return;
}

if (param.apiKey && param.apiKey !== '') {
const payload = {
code: param.apiKey,
client_id: "971735641612-am059p55sofdp30p2t4djecn72l6kmpf.apps.googleusercontent.com",
client_secret: __SECRET__,
redirect_uri: "urn:ietf:wg:oauth:2.0:oob",
grant_type: "authorization_code",
access_type: "offline"
}
$.ajax({
url: "https://www.googleapis.com/oauth2/v4/token",
method: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(payload)
})
.done(response => {
chrome.storage.sync.set({
gapiRefreshToken: response.refresh_token,
gapiToken: response.access_token
}, () => {
login(param);
});
});
} else {
login(param);
}

login(param);
}

function login(param) {
Expand Down Expand Up @@ -292,9 +252,7 @@ function loginBitbucket(param) {
const username = param.username;
const password = param.password;
const baseUrl = param.baseUrl;
const headers = {
Authorization: `Basic RmZIVE02ZnN5NDJQQlJDRjRQOmVDZDN0TTh5TUpUeTJSMld4bTJWUzZoYWVKdnpuNzdw`
}
const headers = {}
$.ajax({
url: 'https://bitbucket.org/site/oauth2/access_token',
headers: headers,
Expand Down Expand Up @@ -468,4 +426,4 @@ function auth() {
}
});
});
}
}