Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ async function init() {
// See #522
// $(document).on('copy', '.markdown-body', copyMarkdown);

domLoaded.then(onDomReady);
await domLoaded;
onDomReady();
}

function onDomReady() {
Expand Down
5 changes: 3 additions & 2 deletions src/features/add-ci-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ let request;

async function fetchStatus() {
const url = `${location.origin}/${getRepoURL()}/commits/`;
const dom = await fetch(url, {
const response = await fetch(url, {
credentials: 'include'
}).then(r => r.text()).then(domify);
});
const dom = domify(await response.text());

const icon = select('.commit-build-statuses', dom);

Expand Down
10 changes: 4 additions & 6 deletions src/features/linkify-branch-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ export function inPR() {
}
}

export function inQuickPR() {
safeElementReady('.branch-name').then(el => {
if (!el) {
return;
}
export async function inQuickPR() {
const el = await safeElementReady('.branch-name');
if (el) {
const {ownerName, repoName} = pageDetect.getOwnerAndRepo();
const branchUrl = `/${ownerName}/${repoName}/tree/${el.textContent}`;
$(el).closest('.branch-name').wrap(<a href={branchUrl}></a>);
});
}
}
7 changes: 4 additions & 3 deletions src/features/mark-unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ function updateLocalParticipatingCount() {

async function setup() {
storage = await new SynchronousStorage(
() => {
return browser.storage.local.get({
async () => {
const storage = await browser.storage.local.get({
unreadNotifications: []
}).then(storage => storage.unreadNotifications);
});
return storage.unreadNotifications;
},
unreadNotifications => {
return browser.storage.local.set({unreadNotifications});
Expand Down
14 changes: 6 additions & 8 deletions src/features/move-account-switcher-to-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import select from 'select-dom';
import {safeElementReady} from '../libs/utils';

export default function () {
safeElementReady('.dashboard-sidebar').then(sidebar => {
const switcher = select('.account-switcher');
if (sidebar && switcher) {
sidebar.prepend(switcher);
}
});
export default async function () {
const sidebar = await safeElementReady('.dashboard-sidebar');
const switcher = select('.account-switcher');
if (sidebar && switcher) {
sidebar.prepend(switcher);
}
}

6 changes: 3 additions & 3 deletions src/features/show-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const getCachedUsers = async () => {
const fetchName = async username => {
// /following/you_know is the lightest page we know
// location.origin is required for Firefox #490
const pageHTML = await fetch(`${location.origin}/${username}/following`)
.then(res => res.text());
const response = await fetch(`${location.origin}/${username}/following`);
const dom = domify(await response.text());

const el = domify(pageHTML).querySelector('h1 strong');
const el = dom.querySelector('h1 strong');

// The full name might not be set
const fullname = el && el.textContent.slice(1, -1);
Expand Down
5 changes: 3 additions & 2 deletions src/features/show-recently-pushed-branches.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export default async function () {
const codeTabURL = select('[data-hotkey="g c"]').href;
const fragmentURL = `/${repoUrl}/show_partial?partial=tree%2Frecently_touched_branches_list`;

const html = await fetch(codeTabURL, {
const response = await fetch(codeTabURL, {
credentials: 'include'
}).then(res => res.text());
});
const html = await response.text();

// https://github.com/sindresorhus/refined-github/issues/216
if (html.includes(fragmentURL)) {
Expand Down
5 changes: 3 additions & 2 deletions src/libs/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default endpoint => {
export default async endpoint => {
const api = location.hostname === 'github.com' ? 'https://api.github.com/' : `${location.origin}/api/`;
return fetch(api + endpoint).then(res => res.json());
const response = await fetch(api + endpoint);
return response.json();
};