-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighlight-Dimensions.user.js
More file actions
executable file
·38 lines (36 loc) · 1.26 KB
/
Copy pathHighlight-Dimensions.user.js
File metadata and controls
executable file
·38 lines (36 loc) · 1.26 KB
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
36
37
38
// ==UserScript==
// @name Highlight Dimensions
// @author horyu (https://github.com/horyu/)
// @namespace https://github.com/horyu/
// @description PDFかOpenAccessのあるarticleを強調表示
// @match https://app.dimensions.ai/discover/publication*
// @version 2020.2.15
// @run-at document-end
// @grant none
// @noframes
// ==/UserScript==
'use strict';
const observer = new MutationObserver(mutationObserverCallback);
const config = { childList: true, subtree: true };
const timerId = setInterval(() => {
const divHasArts = document.querySelector('.resultList');
if (divHasArts) {
observer.observe(divHasArts, config);
clearInterval(timerId)
}
}, 100);
function mutationObserverCallback(mutations) {
try {
mutations.forEach(mutation => {
const node = mutation.target;
if (node.nodeType != Node.ELEMENT_NODE) return;
if (node.matches('.__readcube-access-button')) {
const article = node.closest('.resultList__item');
article.style.backgroundColor = '#cfc';
console.log(article.querySelector('.resultList__item__title__primary').innerText);
}
});
} catch (e) {
console.log(e);
}
}