Last active
July 23, 2017 12:24
-
-
Save matheusfaustino/ba01684b42bb8a6242287212c55ed12c to your computer and use it in GitHub Desktop.
GoMovies "My Movies" enhanced (UserScript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GoMovies "My Movies" enhanced | |
// @namespace gomovies.page.mymovies | |
// @author matheusfaustino | |
// @description Separe movies and series in my movies page | |
// @include https://gostream.is/user/movies/favorite* | |
// @version 1.1.0 | |
// @grant none | |
// ==/UserScript== | |
function sort_by_title(a, b) { c = a.querySelector('.mli-info h2'); d = b.querySelector('.mli-info h2'); return c.innerHTML == d.innerHTML ? 0 : (c.innerHTML > d.innerHTML ? 1 : -1);} | |
function create_div_with_title(title, items) { | |
// create elem | |
let div_html = document.createElement('div'); | |
let title_html = document.createElement('h2'); | |
// style | |
div_html.style.overflow = 'hidden'; | |
title_html.style.margin = '0 1%'; | |
title_html.style.borderBottom = '1px solid rgb(177, 167, 167)'; | |
title_html.style.paddingBottom = '4px'; | |
title_html.style.marginBottom = '10px'; | |
// add content | |
title_html.appendChild(document.createTextNode(title)); | |
div_html.appendChild(title_html); | |
items.map(e => div_html.appendChild(e)) | |
return div_html; | |
} | |
function separeSeriesMovies() { | |
let list_items = [].slice.call(document.querySelectorAll('.movies-list .ml-item')); | |
let list_movies = list_items.filter((x) => x.innerHTML.toLowerCase().indexOf('eps') == -1); | |
let list_series = list_items.filter((x) => x.innerHTML.toLowerCase().indexOf('eps') != -1); | |
list_series.sort(sort_by_title); list_movies.sort(sort_by_title); | |
let movies_html = create_div_with_title('Movies', list_movies); | |
let series_html = create_div_with_title('Series', list_series); | |
document.querySelector('.movies-list').appendChild(movies_html); | |
document.querySelector('.movies-list').appendChild(series_html); | |
} | |
document.addEventListener('DOMContentLoaded', () => separeSeriesMovies() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment