✨ Add observer for picker to ensure picker button is added when page is rebuilt
This commit is contained in:
parent
606bba9c55
commit
ab659cfc89
1 changed files with 13 additions and 5 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Trakt Show Picker
|
// @name Trakt Show Picker
|
||||||
// @namespace danielrayjones
|
// @namespace danielrayjones
|
||||||
// @version 0.0.7
|
// @version 0.0.8
|
||||||
// @description Pick a show from progress page
|
// @description Pick a show from progress page
|
||||||
// @author Dan Jones
|
// @author Dan Jones
|
||||||
// @match https://trakt.tv/users/*/progress*
|
// @match https://trakt.tv/users/*/progress*
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
// @require https://bowercdn.net/c/konami-code-1.3.2/src/jquery.konami.min.js
|
// @require https://bowercdn.net/c/konami-code-1.3.2/src/jquery.konami.min.js
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/* global $, compressedCache, localStorage */
|
/* global $, compressedCache, localStorage, MutationObserver */
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -21,9 +21,17 @@
|
||||||
cheat: pickShow
|
cheat: pickShow
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.subnav-wrapper .container .left')
|
function addPickButton() {
|
||||||
.append('<span class="filter-dropdown pick-episode" title="Pick Episode"><span class="icon trakt-icon-bars"></span></span>')
|
const $leftNav = $('.subnav-wrapper .container .left');
|
||||||
.find('.pick-episode').on('click', pickShow);
|
const $found = $leftNav.find('.pick-episode');
|
||||||
|
if (!$found.length) {
|
||||||
|
$leftNav.append('<span class="filter-dropdown pick-episode" title="Pick Episode"><span class="icon trakt-icon-bars"></span></span>')
|
||||||
|
.find('.pick-episode').on('click', pickShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addPickButton();
|
||||||
|
const observer = new MutationObserver(addPickButton);
|
||||||
|
observer.observe(document.head.parentElement, {childList: true});
|
||||||
|
|
||||||
$('div[data-type="show"]').on('click', function () {
|
$('div[data-type="show"]').on('click', function () {
|
||||||
$(this).removeClass('sortable-ghost');
|
$(this).removeClass('sortable-ghost');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue