-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.user.js
More file actions
63 lines (45 loc) · 2.21 KB
/
script.user.js
File metadata and controls
63 lines (45 loc) · 2.21 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
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
// ==UserScript==
// @name RapidMoviez Scrollable Popular Movies and TV Shows Section
// @description Changes the grid style of "Popular Movies and TV Shows" section of RapidMoviez to a scrollable list mimicking the "Latest Episodes" section.
// @version 2.1
// @namespace io.github.ni554n
// @match http*://rmz.cr/*
// @supportURL https://github.com/ni554n/userscripts/issues
// @license MIT
// @author Nissan Ahmed
// @homepageURL https://ni554n.github.io/
// @contributionURL https://paypal.me/ni554n
// ==/UserScript==
const popularSectionDiv = document.getElementsByClassName("pops clear")[0];
if (!popularSectionDiv) {
console.warn(`Failed to get a reference of the "Popular Movies and TV Shows" section.`);
return;
}
const releaseList = popularSectionDiv.getElementsByTagName("ul")[0];
// Mimic the structure of "Latest Episodes" items.
for (const releaseItem of releaseList?.children) {
// Remove the class in order to reset the current grid style.
releaseItem.removeAttribute("class");
const thumbnailLink = releaseItem.firstElementChild;
// Align the thumbnail image to the left.
thumbnailLink.firstElementChild.setAttribute("align", "left");
// Prepare a clickable link of the release title next to the thumbnail.
const releaseTitleLink = thumbnailLink.cloneNode();
// The link title attribute can be unavailable in some releases. In that case,
// transform the link path to the release title.
releaseTitleLink.textContent = releaseTitleLink.getAttribute("title")
|| releaseTitleLink.getAttribute("href").substring(1)
.split("-")
.map((word) => word.charAt(0).toUpperCase() + word.substring(1))
.join(" ");
const linkSpan = document.createElement("span");
linkSpan.appendChild(releaseTitleLink);
releaseItem.appendChild(linkSpan);
}
// To apply the list style, mimic the div structure of the "Latest Episodes" section.
const div = document.createElement("div");
div.className = "epicontainer";
div.setAttribute("style", "margin: 0px 0 0 -5px; height: 380px");
div.appendChild(releaseList);
popularSectionDiv.className = "latest clear";
popularSectionDiv.appendChild(div);