-
Notifications
You must be signed in to change notification settings - Fork 2
/
basic-title-introspction.js
65 lines (61 loc) · 2.04 KB
/
basic-title-introspction.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// ==UserScript==
// @name iMDB title query
// @namespace https://github.com/Audionut/add-trackers
// @version 1.0.2
// @description Run iMDB queries and introspect the IMDb API
// @author Audionut
// @match https://passthepopcorn.me/torrents.php?id=*
// @icon https://passthepopcorn.me/favicon.ico
// @grant GM_xmlhttpRequest
// @connect api.graphql.imdb.com
// ==/UserScript==
(function () {
'use strict';
const fetchIntrospectionData = async () => {
const url = `https://api.graphql.imdb.com/`;
const query = {
query: `
{
__type(name: "Title") {
name
fields {
name
type {
name
kind
ofType {
name
kind
ofType {
name
kind
}
}
}
}
}
}
`
};
GM_xmlhttpRequest({
method: "POST",
url: url,
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(query),
onload: function (response) {
if (response.status >= 200 && response.status < 300) {
const data = JSON.parse(response.responseText);
console.log("Introspection data:", data);
} else {
console.error("Failed to fetch introspection data", response);
}
},
onerror: function (response) {
console.error("Request error", response);
}
});
};
fetchIntrospectionData();
})();