Skip to content

Commit 6f54708

Browse files
committed
format files uniformly with Rome tools
misc changes for usable twitter trends
1 parent 1a73c77 commit 6f54708

File tree

14 files changed

+260
-206
lines changed

14 files changed

+260
-206
lines changed

britishmuseum.org/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
21
/**
32
* Repair legacy ASPX link by redirecting
43
* to search
54
*/
6-
if (/\/research\/search_the_collection_database\/search_object_(?:details|image).aspx/.test(location.pathname)) {
5+
if (
6+
/\/research\/search_the_collection_database\/search_object_(?:details|image).aspx/.test(
7+
location.pathname,
8+
)
9+
) {
710
const params = new URLSearchParams(location.search.substring(1));
8-
const oid = params.get('objectId') || params.get('objectid');
11+
const oid = params.get("objectId") || params.get("objectid");
912
if (oid) {
1013
location.href = `/collection/search?keyword=${oid}`;
1114
}
12-
}
15+
}

github.com/index.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
2-
import {onBrowse} from './../util.js';
1+
import { onBrowse } from './../util.js';
32

43
onBrowse(() => {
5-
64
// redir deprecated account
7-
if (location.pathname === '/mediawiki') {
8-
location.pathname = '/wikimedia';
5+
if (location.pathname === "/mediawiki") {
6+
location.pathname = "/wikimedia";
97
}
108

119
const fileRegex = /\/([^/]+)\/([^/]+)\/blob\/([^]+)\/(.+)/;
@@ -18,13 +16,12 @@ onBrowse(() => {
1816
const [, user, repo, branch, file] = fileMatch;
1917

2018
const jsd = `https://cdn.jsdelivr.net/gh/${user}/${repo}@${branch}/${file}`;
21-
const a = document.createElement('a');
19+
const a = document.createElement("a");
2220
a.href = jsd;
2321
a.textContent = `JsDelivr`;
2422
a.className = `btn-sm btn BtnGroup-item`;
2523

2624
btns.appendChild(a);
2725
}
2826
}
29-
30-
});
27+
});

google.com/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {onBrowse} from './../util.js';
2-
1+
import { onBrowse } from './../util.js';
32

43
/**
54
* Ensure that "q=" is the last parameter.
@@ -16,14 +15,15 @@ onBrowse(() => {
1615
lastKey = key;
1716
}
1817

19-
if (params.get('tbm')==='isch') {
18+
if (params.get("tbm") === "isch") {
2019
params.sort();
21-
const Q = params.get('q');
22-
if (Q && lastKey !== 'q') { // place query at the end (ezier editing)
23-
params.delete('q');
24-
params.set('q', Q);
25-
const nextHref = location.pathname + '?'+ params.toString();
20+
const Q = params.get("q");
21+
if (Q && lastKey !== "q") {
22+
// place query at the end (ezier editing)
23+
params.delete("q");
24+
params.set("q", Q);
25+
const nextHref = location.pathname + "?" + params.toString();
2626
location.href = nextHref;
2727
}
2828
}
29-
});
29+
});

guidestar.org/index.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
setTimeout(() => {
2-
let bar = document.getElementById('signUpModal');
1+
setTimeout(
2+
() => {
3+
let bar = document.getElementById("signUpModal");
34

4-
if (bar) {
5-
bar.remove();
6-
document.body.className = '';
7-
}
5+
if (bar) {
6+
bar.remove();
7+
document.body.className = "";
8+
}
89

9-
bar = document.querySelector('.modal-backdrop');
10+
bar = document.querySelector(".modal-backdrop");
1011

11-
if (bar) bar.remove();
12+
if (bar) {
13+
bar.remove();
14+
}
1215

13-
bar = document.getElementById('signUpFooter');
16+
bar = document.getElementById("signUpFooter");
1417

15-
if (bar) bar.remove();
16-
}, 500);
18+
if (bar) {
19+
bar.remove();
20+
}
21+
},
22+
500,
23+
);

holy-bhagavad-gita.org/index.js

+35-24
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,55 @@
66
* replace battlefield image with solid color
77
*/
88
const b = document.body;
9-
b.style.background = '#131b42';
10-
b.style.backgroundImage = 'none';
11-
9+
b.style.background = "#131b42";
10+
b.style.backgroundImage = "none";
1211

1312
/**
1413
* remove promotional content for social media
1514
*/
16-
['.fbLikeBoxHolder', '.subscribe'].forEach(css => {
17-
const like = document.querySelector(css);
18-
if (like) like.parentNode.remove();
19-
});
15+
[".fbLikeBoxHolder", ".subscribe"].forEach(
16+
(css) => {
17+
const like = document.querySelector(css);
18+
if (like) {
19+
like.parentNode.remove();
20+
}
21+
},
22+
);
2023

2124
/**
2225
* remove superflous footer text
2326
*/
24-
const copy = document.querySelector('.screen.footer #copyright:nth-of-type(3)');
25-
if (copy) copy.remove();
27+
const copy = document.querySelector(".screen.footer #copyright:nth-of-type(3)");
28+
if (copy) {
29+
copy.remove();
30+
}
2631

2732
/**
2833
* automatically move to next verse
2934
* after audio ends
3035
*/
3136
const verse = document.querySelector("#verseAudio audio");
3237
if (verse) {
33-
verse.onended = () => {
34-
const A = document.querySelector(".verseNav .nextArrow a");
35-
// chapter end
36-
if (A.href === 'javascript:;') {
37-
const B = document.querySelector(".chapterNav .nextArrow a");
38-
B.click();
39-
} else {
40-
A.click();
41-
}
42-
}
38+
verse.onended =
39+
() => {
40+
const A = document.querySelector(".verseNav .nextArrow a");
41+
// chapter end
42+
if (A.href === "javascript:;") {
43+
const B = document.querySelector(".chapterNav .nextArrow a");
44+
B.click();
45+
} else {
46+
A.click();
47+
}
48+
};
49+
try {
50+
verse.play();
51+
} catch (_) {}
4352
}
4453

45-
46-
47-
if (['/index', '/dedication', '/introduction','/publishers-note'].includes(location.pathname.toLowerCase())) {
48-
document.querySelector('aside').remove();
49-
}
54+
if (
55+
["/index", "/dedication", "/introduction", "/publishers-note"].includes(
56+
location.pathname.toLowerCase(),
57+
)
58+
) {
59+
document.querySelector("aside").remove();
60+
}

hook.user.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
*
1313
* @param {Document} d A document to work on
1414
*/
15-
(d => {
16-
const s = d.createElement('script');
17-
s.type = 'module';
18-
s.src = 'https://dra.vin/useascript/index.js';
15+
((d) => {
16+
const s = d.createElement("script");
17+
s.type = "module";
18+
s.src = "https://dra.vin/useascript/index.js";
1919

20-
d.body.appendChild(s);
21-
})(document);
20+
d.body.appendChild(s);
21+
})(document);

index.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
21
let target;
32

4-
switch(location.host) {
5-
case 'github.com':
6-
case 'twitter.com':
7-
case 'mobile.twitter.com': {
8-
/**
3+
switch (location.host) {
4+
case "github.com":
5+
case "twitter.com":
6+
case "mobile.twitter.com":
7+
{
8+
/**
99
* Get root domain
1010
* @see https://stackoverflow.com/a/61381607/270302
1111
*/
12-
const rootDomain = location.host.split('.').slice(-2).join('.');
13-
target = rootDomain;
14-
break;
15-
}
16-
default: {
17-
const domain = location.host.replace('www.', '');
12+
const rootDomain = location.host.split(".").slice(-2).join(".");
13+
target = rootDomain;
14+
break;
15+
}
16+
default:
17+
{
18+
const domain = location.host.replace("www.", "");
1819

19-
switch(domain) {
20-
case 'britishmuseum.org':
21-
case 'holy-bhagavad-gita.org':
22-
case 'google.com':
23-
case 'guidestar.org':
24-
case 'npmjs.com':
25-
case 'reddit.com':
26-
case 'youtube.com':
27-
target = domain;
20+
switch (domain) {
21+
case "britishmuseum.org":
22+
case "holy-bhagavad-gita.org":
23+
case "google.com":
24+
case "ggpht.com":
25+
case "guidestar.org":
26+
case "npmjs.com":
27+
case "reddit.com":
28+
case "youtube.com":
29+
target = domain;
30+
}
2831
}
29-
}
3032
}
3133

32-
3334
if (target) {
3435
console.log(`loading script`, new Date(), target);
3536
await import(`./${target}/index.js`);

npmjs.com/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
21
const pkg = document.querySelector("#top h2 span");
32
if (pkg) {
4-
const bp = document.createElement('a');
3+
const bp = document.createElement("a");
54
bp.href = `https://bundlephobia.com/package/${pkg.textContent}`;
6-
bp.textContent = 'Bundlephobia';
5+
bp.textContent = "Bundlephobia";
76
pkg.parentNode.append(bp);
87

9-
10-
const pp = document.createElement('a');
8+
const pp = document.createElement("a");
119
pp.href = `https://packagephobia.com/result?p=${pkg.textContent}`;
12-
pp.textContent = 'Packagephobia';
10+
pp.textContent = "Packagephobia";
1311
pkg.parentNode.append(pp);
14-
}
12+
}

0 commit comments

Comments
 (0)