This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpage.js
69 lines (63 loc) · 2.77 KB
/
page.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
66
67
68
69
// This file contains functions which determine whether a given description of
// a YouTube page matches the YouTube page associated with a page filter.
// -----------------------------------------------------------------------------
/**
* Reports whether the given YouTube page description matches a channel page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe a channel page.
*/
function isChannelPage(element, _) {
return element.querySelector("ytd-browse[page-subtype=channels]:not([hidden]) #channel-container") !== null;
}
/**
* Reports whether the given YouTube page description matches the Home page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe the Home page.
*/
function isHomePage(_, path) {
return new RegExp("/$").test(path);
}
/**
* Reports whether the given YouTube page description matches the Explore page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe the Explore page.
*/
function isExplorePage(_, path) {
return new RegExp("/feed/explore").test(path);
}
/**
* Reports whether the given YouTube page description matches the Library page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe the Library page.
*/
function isLibraryPage(_, path) {
return new RegExp("/feed/library").test(path);
}
/**
* Reports whether the given YouTube page description matches the History page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe the History page.
*/
function isHistoryPage(_, path) {
return new RegExp("/feed/history").test(path);
}
/**
* Reports whether the given YouTube page description matches the Subscriptions page.
*
* @param {Element} _ - HTML element representing the YouTube page.
* @param {string} path - Path and query components of the YouTube page URL.
* @returns {boolean} - True iff the given element and path describe the Subscriptions page.
*/
function isSubscriptionsPage(_, path) {
return new RegExp("/feed/subscriptions").test(path);
}