355 lines
6.3 KiB
TypeScript
355 lines
6.3 KiB
TypeScript
const STYLE_ID = "ytpf-styles";
|
|
|
|
const CSS = `
|
|
.ytpf-wrapper {
|
|
margin: 16px 0;
|
|
font-family: "Roboto", "Arial", sans-serif;
|
|
font-size: 13px;
|
|
color: var(--yt-spec-text-primary, #0f0f0f);
|
|
}
|
|
|
|
html[dark] .ytpf-wrapper {
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 12px 16px;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
|
|
.ytpf-header-title {
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.ytpf-header-meta {
|
|
font-size: 12px;
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
}
|
|
|
|
html[dark] .ytpf-header-meta {
|
|
color: #aaa;
|
|
}
|
|
|
|
.ytpf-toggle {
|
|
font-size: 12px;
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
transition: transform 0.2s;
|
|
}
|
|
|
|
html[dark] .ytpf-toggle {
|
|
color: #aaa;
|
|
}
|
|
|
|
.ytpf-toggle--collapsed {
|
|
transform: rotate(-90deg);
|
|
}
|
|
|
|
.ytpf-filters {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 8px;
|
|
padding: 8px 16px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.ytpf-filter-input {
|
|
flex: 1;
|
|
min-width: 120px;
|
|
height: 32px;
|
|
box-sizing: border-box;
|
|
padding: 0 10px;
|
|
border: 1px solid var(--yt-spec-10-percent-layer, rgba(0,0,0,0.2));
|
|
border-radius: 8px;
|
|
background: transparent;
|
|
color: var(--yt-spec-text-primary, #0f0f0f);
|
|
font-size: 13px;
|
|
font-family: "Roboto", "Arial", sans-serif;
|
|
outline: none;
|
|
}
|
|
|
|
html[dark] .ytpf-filter-input {
|
|
border-color: rgba(255,255,255,0.2);
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-filter-input:focus {
|
|
border-color: var(--yt-spec-call-to-action, #065fd4);
|
|
}
|
|
|
|
html[dark] .ytpf-filter-input:focus {
|
|
border-color: #3ea6ff;
|
|
}
|
|
|
|
.ytpf-filter-input::placeholder {
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
}
|
|
|
|
html[dark] .ytpf-filter-input::placeholder {
|
|
color: #aaa;
|
|
}
|
|
|
|
.ytpf-tag-input {
|
|
position: relative;
|
|
flex: 1;
|
|
min-width: 160px;
|
|
min-height: 32px;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 4px;
|
|
padding: 3px 8px;
|
|
border: 1px solid var(--yt-spec-10-percent-layer, rgba(0,0,0,0.2));
|
|
border-radius: 8px;
|
|
background: transparent;
|
|
align-items: center;
|
|
cursor: text;
|
|
}
|
|
|
|
html[dark] .ytpf-tag-input {
|
|
border-color: rgba(255,255,255,0.2);
|
|
}
|
|
|
|
.ytpf-tag-input:focus-within {
|
|
border-color: var(--yt-spec-call-to-action, #065fd4);
|
|
}
|
|
|
|
html[dark] .ytpf-tag-input:focus-within {
|
|
border-color: #3ea6ff;
|
|
}
|
|
|
|
.ytpf-tag {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
height: 24px;
|
|
box-sizing: border-box;
|
|
padding: 0 8px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
line-height: 24px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.ytpf-tag-remove {
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
line-height: 1;
|
|
opacity: 0.6;
|
|
}
|
|
|
|
.ytpf-tag-remove:hover {
|
|
opacity: 1;
|
|
}
|
|
|
|
.ytpf-tag-text-input {
|
|
border: none;
|
|
outline: none;
|
|
background: transparent;
|
|
color: var(--yt-spec-text-primary, #0f0f0f);
|
|
font-size: 13px;
|
|
font-family: "Roboto", "Arial", sans-serif;
|
|
flex: 1;
|
|
min-width: 30px;
|
|
height: 24px;
|
|
padding: 0;
|
|
}
|
|
|
|
html[dark] .ytpf-tag-text-input {
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-tag-text-input::placeholder {
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
}
|
|
|
|
html[dark] .ytpf-tag-text-input::placeholder {
|
|
color: #aaa;
|
|
}
|
|
|
|
.ytpf-autocomplete {
|
|
position: absolute;
|
|
top: 100%;
|
|
left: 0;
|
|
right: 0;
|
|
margin-top: 4px;
|
|
background: #fff;
|
|
border: 1px solid rgba(0,0,0,0.1);
|
|
border-radius: 8px;
|
|
max-height: 200px;
|
|
overflow-y: auto;
|
|
z-index: 2000;
|
|
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
html[dark] .ytpf-autocomplete {
|
|
background: #282828;
|
|
border-color: rgba(255,255,255,0.1);
|
|
}
|
|
|
|
.ytpf-autocomplete-item {
|
|
padding: 6px 12px;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
color: #0f0f0f;
|
|
}
|
|
|
|
html[dark] .ytpf-autocomplete-item {
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-autocomplete-item:hover,
|
|
.ytpf-autocomplete-item--active {
|
|
background: #f2f2f2;
|
|
}
|
|
|
|
html[dark] .ytpf-autocomplete-item:hover,
|
|
html[dark] .ytpf-autocomplete-item--active {
|
|
background: #3e3e3e;
|
|
}
|
|
|
|
.ytpf-filters--hidden {
|
|
display: none;
|
|
}
|
|
|
|
.ytpf-filter-count {
|
|
font-size: 12px;
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
align-self: center;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
html[dark] .ytpf-filter-count {
|
|
color: #aaa;
|
|
}
|
|
|
|
.ytpf-body {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.ytpf-body--hidden {
|
|
display: none;
|
|
}
|
|
|
|
.ytpf-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
table-layout: fixed;
|
|
}
|
|
|
|
.ytpf-th {
|
|
text-align: left;
|
|
padding: 8px 12px;
|
|
font-weight: 500;
|
|
font-size: 12px;
|
|
color: var(--yt-spec-text-secondary, #606060);
|
|
border-bottom: 1px solid var(--yt-spec-10-percent-layer, rgba(0,0,0,0.1));
|
|
white-space: nowrap;
|
|
}
|
|
|
|
html[dark] .ytpf-th {
|
|
color: #aaa;
|
|
border-bottom-color: rgba(255,255,255,0.1);
|
|
}
|
|
|
|
.ytpf-th--sortable {
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
|
|
.ytpf-th--sortable:hover {
|
|
color: var(--yt-spec-text-primary, #0f0f0f);
|
|
}
|
|
|
|
html[dark] .ytpf-th--sortable:hover {
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-th--sortable::after {
|
|
content: "";
|
|
margin-left: 4px;
|
|
}
|
|
|
|
.ytpf-th[data-sort-dir="asc"]::after {
|
|
content: " \\25B2";
|
|
}
|
|
|
|
.ytpf-th[data-sort-dir="desc"]::after {
|
|
content: " \\25BC";
|
|
}
|
|
|
|
.ytpf-td {
|
|
padding: 6px 12px;
|
|
border-bottom: 1px solid var(--yt-spec-10-percent-layer, rgba(0,0,0,0.1));
|
|
vertical-align: middle;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
html[dark] .ytpf-td {
|
|
border-bottom-color: rgba(255,255,255,0.1);
|
|
}
|
|
|
|
.ytpf-tr:hover {
|
|
background: var(--yt-spec-badge-chip-background, #f2f2f2);
|
|
}
|
|
|
|
html[dark] .ytpf-tr:hover {
|
|
background: #272727;
|
|
}
|
|
|
|
.ytpf-col-index { width: 48px; text-align: right; }
|
|
.ytpf-col-title { width: auto; }
|
|
.ytpf-col-channel { width: 180px; }
|
|
.ytpf-col-duration { width: 80px; font-family: "Roboto Mono", monospace; }
|
|
.ytpf-col-addedby { width: 140px; }
|
|
.ytpf-col-votes { width: 60px; text-align: center; font-family: "Roboto Mono", monospace; }
|
|
.ytpf-tr--unplayable {
|
|
opacity: 0.45;
|
|
}
|
|
|
|
.ytpf-tr--unplayable .ytpf-link {
|
|
text-decoration: line-through;
|
|
}
|
|
|
|
.ytpf-link {
|
|
color: var(--yt-spec-text-primary, #0f0f0f);
|
|
text-decoration: none;
|
|
}
|
|
|
|
html[dark] .ytpf-link {
|
|
color: #f1f1f1;
|
|
}
|
|
|
|
.ytpf-link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.ytpf-live {
|
|
display: inline-block;
|
|
padding: 1px 6px;
|
|
border-radius: 4px;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
background: #c00;
|
|
color: #fff;
|
|
}
|
|
`;
|
|
|
|
export function injectStyles(): void {
|
|
if (document.getElementById(STYLE_ID)) return;
|
|
const style = document.createElement("style");
|
|
style.id = STYLE_ID;
|
|
style.textContent = CSS;
|
|
document.head.appendChild(style);
|
|
}
|
|
|
|
export function removeStyles(): void {
|
|
document.getElementById(STYLE_ID)?.remove();
|
|
}
|