blob: ca3562db7ece735288f946d8f239ee66cdb547f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
const isSingleHTMLFile = (): boolean => pageDetect.isSingleFile() && /\.html?$/.test(location.pathname);
function init(): void {
const rawButton = select<HTMLAnchorElement>('#raw-url')!;
rawButton
.parentElement! // `BtnGroup`
.prepend(
<a
className="btn btn-sm BtnGroup-item"
href={`https://refined-github-html-preview.kidonng.workers.dev${rawButton.pathname}`}
>
Preview
</a>
);
}
void features.add({
id: __filebasename,
description: 'Adds a link to preview HTML files.',
screenshot: 'https://user-images.githubusercontent.com/44045911/67634792-48995980-f8fb-11e9-8b6a-7b57d5b12a2f.png'
}, {
include: [
isSingleHTMLFile
],
exclude: [
pageDetect.isEnterprise
],
init
});
|