-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-twitter-list.user.js
48 lines (39 loc) · 1.32 KB
/
show-twitter-list.user.js
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
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name [Deprecated] Show Twitter List
// @namespace https://wiki.gslin.org/wiki/ShowTwitterList
// @version 0.20190530.0
// @description Show twitter list in title.
// @author Gea-Suan Lin <darkkiller@gmail.com>
// @match https://twitter.com/*
// @grant none
// @run-at document-end
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Don't run this script inside iframe.
if (window !== top) {
return;
}
const url_re = new RegExp('^https://twitter\.com/[^/]+(/media)?$');
if (!document.location.href.match(url_re)) {
return;
}
let user_id = document.querySelector('.ProfileNav[data-user-id]').getAttribute('data-user-id');
let url = '/i/' + user_id + '/lists';
console.debug('Trying to fetch ' + url);
fetch(url).then(res => {
return res.json();
}).then(j => {
let h = document.createElement('div');
h.innerHTML = j.html;
console.debug('Got ' + url, h);
let c = h.querySelector('.membership-checkbox[checked="checked"]');
if (!c) {
return;
}
let l = c.parentElement.innerText.trim();
let title = document.getElementsByTagName('title')[0];
title.innerHTML = '(' + l + ') ' + title.innerHTML;
});
})();