Skip to content

Instantly share code, notes, and snippets.

@unarist
Created March 13, 2025 18:37
Show Gist options
  • Save unarist/422468a7196727b85f8cc75b2a9e61bf to your computer and use it in GitHub Desktop.
Save unarist/422468a7196727b85f8cc75b2a9e61bf to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name tonton - copy&paste
// @namespace https://github.com/unarist/
// @version 2025-03-13
// @description Add copy&paste feature to tonton
// @author unarist
// @match https://tonton.amaneku.com/list.php?*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tonton.amaneku.com
// @grant none
// @downloadURL https://gist.github.com/unarist/422468a7196727b85f8cc75b2a9e61bf/raw/tonton-copy-paste.user.js
// @run-at document-idle
// @noframes
// ==/UserScript==
(function() {
'use strict';
const t = (n, p = {}) => Object.assign(document.createElement(n), p);
const symAttached = Symbol();
let copied = null
function update(mod) {
const prevColor = MT_timelineSetNum;
MT_setTimeselMemberUpdateInit(mod(timeScheduleArr))
MT_setTimelineColor(prevColor);
}
const actions = {
copy: i => copied = timeScheduleArr[i],
paste: i => copied && update(schedule => schedule.toSpliced(i,1,copied)),
all: i => update(schedule => schedule.map(() => timeScheduleArr[i]))
}
new MutationObserver(() => {
const table = document.querySelector('#schedule_list');
if (!table || table[symAttached]) return;
table.querySelectorAll('#schedule_list .tablestyle-01').forEach((tr, i) => {
const header = tr.querySelector('.nowrap-pop')
header.style.overflow = '';
header.append(
t("br"),
...Object.entries(actions).map(([l,f]) => t("a", { href: "javascript:void()", textContent: l, style: "font-size: .9em; margin-right: 1em", onclick: () => f(i) }))
);
});
}).observe(document.body, {childList:1, deep:1})
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment