`;
a.onclick = e => {
(e.target === a) && a.remove();
};
(b = a.querySelector("#mwyvrhi_ujs")).onchange = r => {
r = new FileReader();
r.onload = (o, t) => {
if (o = parseData(r = r.result)) { //parse as native format
if (o.index.length) {
askRestore(o);
} else alert("File doesn't contain any history entry.");
} else if (o = parseYouTubeData(r)) { //parse as YouTube format
if (o.index.length) {
askRestore(o);
} else alert("File doesn't contain any history entry.");
} else { //parse as URL list
o = {entries: {}, index: []};
t = (new Date()).getTime();
r = r.replace(/\r/g, "").split("\n");
while (r.length && !r[0].trim()) r.shift();
if (r.length && xu.test(r[0])) {
r.forEach(s => {
if (s = s.match(xu)) {
o.entries[s[1] || s[2]] = t;
o.index.push(s[1] || s[2]);
}
});
if (o.index.length) {
askRestore(o);
} else alert("File doesn't contain any history entry.");
} else alert("Invalid history data file.");
}
};
r.readAsText(b.files[0]);
};
document.documentElement.appendChild(a);
b.click();
});
}
var styles = [], intervals = [];
function addInterval(period, func, params) {
if (!period) period = 1;
intervals.push({
cnt: period,
period: period,
call: func,
params: params || []
});
}
function genSettings() {
if (document.location.pathname == "/error")
return;
GM_config.init({
"id": "settings-7kt",
"title": "7ktTube 2016 REDUX Settings",
"fields": {
"shorts_redirect": {
"label": "Redirect shorts to classic watch-page",
"type": "checkbox",
"default": false
},
"old_player": {
"label": "Old player style (smaller buttons and menu)",
"type": "checkbox",
"default": true
},
"search_left": {
"label": "Align the searchbar to the left",
"type": "checkbox",
"default": true
},
"hide_guide": {
"label": "Compact side-bar",
"type": "checkbox",
"default": false
},
"square_pfps": {
"label": "Square profile-pictures",
"type": "checkbox",
"default": true
},
"thumb_preview": {
"label": "Disable thumbnail video preview while mouse over",
"type": "checkbox",
"default": false
},
"hide_info_card": {
"label": "Hide panels in video description on watch-page ",
"type": "checkbox",
"default": true
},
"hide_clarify_box": {
"label": "Hide Metadata panels below description ",
"type": "checkbox",
"default": false
},
"hide_channel_store": {
"label": "Hide channel-store / merch on watch page",
"type": "checkbox",
"default": true
},
"hide_queue": {
"label": "Hide queue button on thumbnails",
"type": "checkbox",
"default": false
},
"hide_filters_header": {
"label": "Hide category filter on home page",
"type": "checkbox",
"default": true
},
"hide_yt_suggested_blocks": {
"label": "Hide Shorts & suggestion blocks on home page (recommended playlists, posts, etc.)",
"type": "checkbox",
"default": true
},
"grey_watched": {
"label": "Make watched video thumbnails black & white and less visible",
"type": "checkbox",
"default": true
},
"blur_watched": {
"label": "Blur watched video thumbnails",
"type": "checkbox",
"default": true
},
"channel_list": {
"label": "Use list view on channels",
"type": "checkbox",
"default": false
},
"small_recc": {
"label": "Smaller recommended thumbnails on watch page",
"type": "checkbox",
"default": true
},
"use_ryd": {
"label": "",
"type": "hidden",
},
"full_subs": {
"label": "Enable full subscriber counts (estimation)",
"type": "checkbox",
"default": true
},
"clear_search": {
"label": "Hide unrelated suggestion blocks on search page",
"type": "checkbox",
"default": true
},
"restore_old_sidebar": {
"label": "Restore old sidebar links (Trending, My channel)",
"title": "(will only work if language is set to English)",
"type": "checkbox",
"default": true
},
"shelves": {
"label": "",
"type": "hidden",
},
"search_estimate": {
"label": "Show estimates in search results",
"type": "checkbox",
"default": true
},
"rightside": {
"label": "CHECK this if you use the Right Side Description extension",
"type": "checkbox",
"default": false
},
"logo_style": {
"label": "Top header Logo style:",
"type": "select",
"options": ["7ktTube", "2015-2017", "2017-2020", "Current"],
"default": "7ktTube"
},
"home_thumbnail": {
"label": "Home thumbnail size:",
"type": "select",
"options": ["196px", "238px", "300px", "406px"],
"default": "196px"
},
"search_thumbnail": {
"label": "Search thumbnail size:",
"type": "select",
"options": ["193px", "246px", "360px"],
"default": "246px"
},
"player_size": {
"label": "Video player size:",
"type": "select",
"options": ["Flexible", "640x360", "853x480", "1280x720"],
"default": "853x480"
},
"paypal": {
"label": "Donate through PayPal (please!)",
"type": "button",
"click": () => location.href = 'https://www.paypal.com/donate?hosted_button_id=2EJR4DLTR4Y7Q'
}
},
"events": {
"open": injectStyles,
"save": () => document.location.reload()
}
});
// "settings" button
let settingsButtonMark;
function createSettingsButton() {
if (settingsButtonMark && settingsButtonMark.parentNode) return;
let toolBar = document.getElementsByTagName('ytd-topbar-menu-button-renderer');
let _1st = toolBar[0];
if (!_1st) return;
toolBar = _1st.parentNode;
let sb = document.createElement('ytd-topbar-menu-button-renderer');
sb.className = 'style-scope ytd-masthead style-default';
sb.setAttribute('use-keyboard-focused', '');
sb.setAttribute('is-icon-button', '');
sb.setAttribute('has-no-text', '');
toolBar.insertBefore(sb, toolBar.childNodes[0]);
let mark = document.createElement('fix-settings-mark');
mark.style = 'display:none';
toolBar.insertBefore(mark, sb); // must be added to parent node of buttons in order to Polymer dropped it on soft reload
let icb = document.createElement('yt-icon-button');
icb.id = 'button';
icb.className = 'style-scope ytd-topbar-menu-button-renderer style-default';
let aa = document.createElement('a');
aa.className = 'yt-simple-endpoint style-scope ytd-topbar-menu-button-renderer';
aa.setAttribute('tabindex', '-1');
aa.target = '_blank';
aa.appendChild(icb);
sb.getElementsByTagName('div')[0].appendChild(aa); // created by YT scripts
let bb = icb.getElementsByTagName('button')[0]; // created by YT scripts
bb.setAttribute('aria-label', 'fixes settings');
bb.addEventListener("click", () => GM_config.open());
let ic = document.createElement('yt-icon');
ic.className = 'style-scope ytd-topbar-menu-button-renderer';
bb.appendChild(ic);
let gpath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
gpath.className.baseVal = 'style-scope yt-icon';
gpath.setAttribute('d', 'M1 20l6-6h2l11-11v-1l2-1 1 1-1 2h-1l-11 11v2l-6 6h-1l-2-2zM13 15l2-2 8 8v1l-1 1h-1zM9 11l2-2-2-2 1.5-3-3-3h-2l3 3-1.5 3-3 1.5-3-3v2l3 3 3-1.5z');
let svgg = document.createElementNS('http://www.w3.org/2000/svg', 'g');
svgg.className.baseVal = 'style-scope yt-icon';
svgg.appendChild(gpath);
let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.className.baseVal = 'style-scope yt-icon';
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
svg.setAttributeNS(null, 'preserveAspectRatio', 'xMidYMid meet');
svg.setAttribute('focusable', 'false');
svg.setAttribute('style', 'pointer-events: none; display: block; width: 100%; height: 100%;');
svg.appendChild(svgg);
ic.appendChild(svg); // YT clears *ic
settingsButtonMark = mark;
}
addInterval(1, createSettingsButton, []);
if (GM_config.get("old_player"))
applyOldPlayer();
if (GM_config.get("search_left"))
alignSearchbar();
if (GM_config.get("hide_guide"))
hideGuide();
if (GM_config.get("square_pfps"))
squarePFPs();
if (GM_config.get("thumb_preview"))
disablePreviews();
if (GM_config.get("hide_info_card") && window.location.href.includes('watch'))
hideInfoCards();
if (GM_config.get("hide_clarify_box"))
hideClarifyBox();
if (GM_config.get("hide_queue"))
hideQueue();
if (GM_config.get("hide_filters_header"))
hideHomeFilters();
if (GM_config.get("hide_channel_store"))
hideChannelStore();
if (GM_config.get("hide_yt_suggested_blocks"))
hideSuggestionBlocks();
if (GM_config.get("channel_list"))
channelListView();
if (GM_config.get("small_recc"))
smallRecommendations();
if (GM_config.get("clear_search"))
hideSearchBlocks();
if (GM_config.get("restore_old_sidebar"))
waitForElement('#items > ytd-guide-entry-renderer').then(restoreAppbarLinks);
if (GM_config.get("shelves"))
enableHomeShelves();
if (GM_config.get("search_estimate"))
window.addEventListener("yt-page-data-updated", insertResultsEstimate, false);
if (!GM_config.get("rightside"))
patchNonRSD();
if (GM_config.get("rightside"))
fixRSD();
if (GM_config.get("logo_style") == "2015-2017")
use2015Logo();
if (GM_config.get("logo_style") == "2017-2020")
use2017Logo();
if (GM_config.get("logo_style") == "7ktTube")
use7ktLogo();
if (GM_config.get("shorts_redirect"))
redir_shorts();
if (GM_config.get("blur_watched")) {
if (GM_config.get("grey_watched"))
greyAndBlurWatched();
else
blurWatched();
} else if (GM_config.get("grey_watched")) {
greyWatched();
}
if (GM_config.get("use_ryd")) {
addRYDStyles();
window.addEventListener("yt-page-data-updated", returnDislike, false);
}
if (GM_config.get("full_subs")) {
addFullSubsStyles();
window.addEventListener("yt-page-data-updated", estimateSubs, false);
}
patchHomeThumbnails(GM_config.get("home_thumbnail"));
patchSearchThumbnails(GM_config.get("search_thumbnail"));
patchPlayerSize(GM_config.get("player_size"));
GM_addStyle(styles.join(''));
// intervals
setInterval(function () {
for (const iv of intervals) {
if (--iv.cnt > 0) continue;
iv.call.apply(this, iv.params);
iv.cnt = iv.period;
}
}, 1000);
}
function injectStyles(settingsDoc) {
var css = `
#settings-7kt select {
width: 85px;
margin-top: 20px;
margin-left: 25px;
}
#settings-7kt_home_thumbnail_field_label {
position: absolute;
margin: 0px -10px !important;
}
#settings-7kt_player_size_field_label {
position: absolute;
margin: 0px -10px !important;
}
#settings-7kt_search_thumbnail_field_label {
position: absolute;
margin: 0px -10px !important;
}
#settings-7kt_logo_style_field_label {
position: absolute;
margin: 0px -10px !important;
}
#settings-7kt input[type="checkbox"] {
position: absolute;
left:0;
margin-left:6px;
width: 30px;
height: 12px;
-webkitappearance: none;
appearance: none;
background: #b8b8b8;
outline: none;
border-radius: 2rem;
cursor: pointer;
background-size: 200px;
background-position-y: 37%;
background-position-x: 22%;
}
#settings-7kt input[type="checkbox"]::before {
content: "";
width: 11px;
height: 11px;
border-radius: 50%;
background: #fbfbfb;
position: absolute;
box-shadow: 1px 1px 2px 1px rgb(0 0 0 / 20%);
top: 0;
left: 0;
transition: 0.5s;
}
#settings-7kt input[type="checkbox"]:checked::before {
transform: translateX(164%);
background: #fbfbfb
}
#settings-7kt input[type="checkbox"]:checked {
background:#167ac6 no-repeat url(//s.ytimg.com/yts/imgbin/www-hitchhiker-vfllYIUv0.png);
background-size:180px;
background-position-y: 37%;
background-position-x: 22%;
}
#settings-7kt input[type="checkbox"]:checked::before {
transform: translateX(165%);
background: #fff
}
#settings-7kt input[type="checkbox"]:checked {
background:#167ac6 no-repeat url(//s.ytimg.com/yts/imgbin/www-hitchhiker-vfllYIUv0.png);
background-size: 200px;
background-position-y: 37%;
background-position-x: 22%;
}
}
#settings-7kt * {
font-family: Roboto, Arial, sans-serif;
}
#settings-7kt .config_var {
margin: 0px 10px 2px !important;
}
#settings-7kt .config_var::after {
content: "";
position: absolute;
display: inline-block;
left: 540px;
top: 300px;
width: 390px;
height: 190px;
background-size: 100%;
}
#settings-7kt .field_label {
cursor: pointer;
line-height: 20px;
margin-left: 25px;
}
#settings-7kt_old_player_var:hover::after {
background: url(https://7kt.se/resources/images/old-player.png);
}
#settings-7kt_search_left_var:hover::after {
background: url(https://7kt.se/resources/images/searchbar.png);
}
#settings-7kt_hide_guide_var:hover::after {
background: url(https://7kt.se/resources/images/auto-close-menu.png);
}
#settings-7kt_square_pfps_var:hover::after {
background: url(https://7kt.se/resources/images/square-avatars.png);
}
#settings-7kt_hide_info_card_var:hover::after {
background: url(https://7kt.se/resources/images/hide-info-card.png);
}
#settings-7kt_hide_clarify_box_var:hover::after {
background: url(https://7kt.se/resources/images/hide-clarify-box.png);
}
#settings-7kt_hide_channel_store_var:hover::after {
background: url(https://7kt.se/resources/images/hide-store.png);
}
#settings-7kt_hide_queue_var:hover::after {
background: url(https://7kt.se/resources/images/hide-queue-button.png);
}
#settings-7kt_hide_filters_header_var:hover::after {
background: url(https://7kt.se/resources/images/hide-filters.png);
}
#settings-7kt_hide_yt_suggested_blocks_var:hover::after {
background: url(https://7kt.se/resources/images/recommended-home.png);
}
#settings-7kt_grey_watched_var:hover::after {
background: url(https://7kt.se/resources/images/grey-watched.png);
}
#settings-7kt_blur_watched_var:hover::after {
background: url(https://7kt.se/resources/images/blur-watched.png);
}
#settings-7kt_channel_list_var:hover::after {
background: url(https://7kt.se/resources/images/listview-channel.png);
}
#settings-7kt_small_recc_var:hover::after {
background: url(https://7kt.se/resources/images/small-recommended.png);
}
#settings-7kt_hide_dislike_var:hover::after {
background: url(https://7kt.se/resources/images/hide-dislike.png);
}
#settings-7kt_full_subs_var:hover::after {
background: url(https://7kt.se/resources/images/full-sub.png);
}
#settings-7kt_clear_search_var:hover::after {
background: url(https://7kt.se/resources/images/recommended-search.png);
}
#settings-7kt_shelves_var:hover::after {
background: url(https://7kt.se/resources/images/replace-explore.png);
}
#settings-7kt_logo_style_var:hover::after {
background: url(https://7kt.se/resources/images/logo-style.png);
}
#settings-7kt_wrapper #settings-7kt_closeBtn, #settings-7kt_field_paypal {
margin: 15px 0px 0px 0px;
}
.saveclose_buttons, #settings-7kt_field_paypal {
border-radius: 2px;
cursor: pointer;
font: bold 11px arial !important;
padding: 0 10px !important;
height: 28px;
box-shadow: 0 1px 0 rgb(0 0 0/5%) !important;
border: 1px transparent;
}
#settings-7kt_closeBtn, #settings-7kt_field_paypal {
background-color: #f8f8f8 !important;
border: solid 1px #d3d3d3 !important;
color: #000 !important;
}
#settings-7kt_closeBtn:hover, #settings-7kt_field_paypal:hover {
border-color: #c6c6c6 !important;
background-color: #f0f0f0 !important;
box-shadow: 0 1px 0 rgb(0 0 0/10%) !important;
}
#settings-7kt_closeBtn:active, #settings-7kt_field_paypal:active {
background-color: #e9e9e9 !important;
box-shadow: inset 0 1px 0 #ddd !important;
}
#settings-7kt_saveBtn {
background-color: #167ac6 !important;
color: #fff !important;
border-color: #167ac6 !important;
}
#settings-7kt_saveBtn:hover {
background-color: #126db3 !important;
border-color: #126db3 !important;
}
#settings-7kt_saveBtn:active {
background-color: #095b99 !important;
border-color: #126db3 !important;
box-shadow: inset 0 1px 0 rgb(0 0 0/50%) !important;
}
#settings-7kt_buttons_holder {
text-align: left!important;
margin: 16px 0px 10px !important;
}
#settings-7kt .center {
text-align:left;
margin-bottom: 10px!important;
text-decoration: underline;
}
#settings-7kt_resetLink {
margin-left: 10px!important;
}`;
if (document.documentElement.hasAttribute("dark"))
{
css += `
#settings-7kt {
background: #212121;
color: #fff;
}
#settings-7kt select,
#settings-7kt input[type="button"],
#settings-7kt .saveclose_buttons {
background: #1c1c1c;
color: #fff;
border-color: rgba(110, 110, 110, 0.3);
}
#settings-7kt .reset {
color: #fff;
}
#settings-7kt_wrapper #settings-7kt_closeBtn, #settings-7kt_field_paypal {
background-color: #1c1c1c !important;
border: solid 1px #333 !important;
color: #fff !important;
margin: 15px 0px 0px 0px;
}
#settings-7kt_wrapper #settings-7kt_closeBtn:hover, #settings-7kt_field_paypal:hover {
border-color: #3c3c3c !important;
background-color: #444 !important;
box-shadow: 0 1px 0 rgb(0 0 0/10%) !important;
}
#settings-7kt_wrapper #settings-7kt_closeBtn:active, #settings-7kt_field_paypal:active {
background-color: #555 !important;
box-shadow: 0 1px 0 rgb(0 0 0/10%) !important;
}`;
}
let style = settingsDoc.createElement("style");
style.type = "text/css";
style.appendChild(settingsDoc.createTextNode(css));
const head = settingsDoc.getElementsByTagName("head")[0];
head.appendChild(style);
}
async function estimateSubs() {
async function getSubCount(channelID) {
let subs, retries = 0;
while (typeof subs === "undefined" && retries < 5) {
retries++;
try {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), 2000);
const apiResponse = await fetch(`https://api.socialcounts.org/youtube-live-subscriber-count/${channelID}`, { signal: controller.signal });
clearTimeout(id);
const apiResult = await apiResponse.json();
if (apiResult) {
subs = apiResult.est_sub;
if (typeof subs !== "undefined")
return Number.isInteger(subs) ? subs.toLocaleString() : "0";
}
} catch(e) { console.log(`Getting full sub count failed (attempt ${retries}/5)`); }
}
console.log("Get full sub count failed after 3 attempts!");
return "FAILED";
}
const resultsObserver = new MutationObserver(async function(mutations) {
var subscribersTranslation;
for (const elm of document.querySelectorAll("ytd-channel-renderer:not([patched7kt])")) {
elm.setAttribute("patched7kt", "");
const channelID = elm.data.channelId;
const subCountElm = elm.querySelector("#subscribers");
const estSubText = subCountElm.innerText;
if (!estSubText.length)
continue;
if (!subscribersTranslation)
subscribersTranslation = estSubText.slice(estSubText.lastIndexOf(" "));
subCountElm.innerText = "";
const subCount = await getSubCount(channelID);
subCountElm.innerText = subCount != "FAILED" ? subCount + subscribersTranslation : estSubText;
}
});
if (window.location.pathname == "/watch") {
const channelID = document.querySelector("ytd-app").data.playerResponse.videoDetails.channelId;
const subCountElm = await waitForElement("#top-row #owner-sub-count.ytd-video-owner-renderer");
const estSubText = subCountElm.innerText;
const subscribersTranslation = estSubText.slice(estSubText.lastIndexOf(" "));
subCountElm.innerText = "";
const subCount = await getSubCount(channelID);
subCountElm.innerText = subCount != "FAILED" ? subCount : estSubText.replace(subscribersTranslation, "");
} else if (window.location.pathname.startsWith("/c/") || window.location.pathname.startsWith("/channel") || window.location.pathname.startsWith("/user")) {
const channelID = document.querySelector("ytd-app").data.response.header.c4TabbedHeaderRenderer.channelId;
const subCountElm = await waitForElement("#subscriber-count.ytd-c4-tabbed-header-renderer");
const estSubText = subCountElm.innerText;
const subscribersTranslation = estSubText.slice(estSubText.lastIndexOf(" "));
subCountElm.innerText = "";
const subCount = await getSubCount(channelID);
subCountElm.innerText = subCount != "FAILED" ? subCount : estSubText.replace(subscribersTranslation, "");
} else if (window.location.pathname == "/results") {
const resultsList = await waitForElement("ytd-two-column-search-results-renderer #contents.ytd-section-list-renderer");
resultsObserver.observe(resultsList, { childList: true, subtree: true });
}
}
function addFullSubsStyles() {
styles.push(`
#top-row #owner-sub-count.ytd-video-owner-renderer,
#subscriber-count.ytd-c4-tabbed-header-renderer {
max-width: 100% !important;
}
`);
}
function patchPlayerSize(size) {
if (size == "Flexible")
return;
const split = size.split("x");
const width = split[0];
const height = split[1];
const sizeObj = { w: width, h: height };
styles.push(`
#primary.ytd-watch-flexy, #player-container-outer {
--ytd-watch-flexy-min-player-width: ${height}px !important;
min-width: --ytd-watch-flexy-min-player-width: 100% !important;
max-width: ${width}px !important
}
ytd-watch-flexy[flexy_][is-two-columns_][is-extra-wide-video_] #primary.ytd-watch-flexy, ytd-watch-flexy[flexy_][is-two-columns_][is-four-three-to-sixteen-nine-video_] #primary.ytd-watch-flexy {
min-width: ${width}px!important
}
ytd-watch-flexy[flexy_][flexy-large-window_]:not([is-extra-wide-video_]), ytd-watch-flexy[flexy_][flexy-large-window_][transcript-opened_][is-two-columns_]:not([is-extra-wide-video_]), ytd-watch-flexy[flexy_][flexy-large-window_][playlist][is-two-columns_]:not([is-extra-wide-video_]), ytd-watch-flexy[flexy_][flexy-large-window_][should-stamp-chat][is-two-columns_]:not([is-extra-wide-video_]) {
--ytd-watch-flexy-min-player-height: ${height}px !important;`);
addInterval(1, function (sn, st) {
let eq = document.getElementsByTagName("ytd-watch-flexy");
if (!eq.length) return;
let s = eq[0].hasAttribute('size_norm') ? st : sn;
if (!s) return;
let ep = document.getElementById("movie_player");
if (ep && ep.setInternalSize && ep.isFullscreen && ep.getPlayerSize && !ep.isFullscreen() && ep.getPlayerSize().width != s[0])
ep.setInternalSize(s[0], s[1]);
}, [sizeObj]);
}
function patchSearchThumbnails(size) {
styles.push(`
#contents ytd-video-renderer:not([use-prominent-thumbs]) ytd-thumbnail.ytd-video-renderer,
ytd-video-renderer[use-prominent-thumbs] ytd-thumbnail.ytd-video-renderer,
ytd-video-renderer[is-search] ytd-thumbnail.ytd-video-renderer,
ytd-video-renderer[use-prominent-thumbs] #channel-info.ytd-video-renderer,
ytd-playlist-renderer[use-prominent-thumbs] ytd-playlist-thumbnail.ytd-playlist-renderer,
ytd-radio-renderer[use-prominent-thumbs] ytd-thumbnail.ytd-radio-renderer,
ytd-playlist-renderer[is-search] ytd-playlist-thumbnail.ytd-playlist-renderer,
ytd-thumbnail.ytd-radio-renderer,
ytd-video-renderer[use-bigger-thumbs] ytd-thumbnail.ytd-video-renderer,
ytd-video-renderer[use-bigger-thumbs][bigger-thumbs-style="BIG"] ytd-thumbnail.ytd-video-renderer,
#contents .yt-lockup-view-model-wiz--horizontal .yt-lockup-view-model-wiz__content-image,
#avatar-section.ytd-channel-renderer, ytd-radio-renderer[collections] ytd-playlist-thumbnail.ytd-radio-renderer {
max-width: ${size} !important;
min-width: 0px !important;
}`);
}
function patchHomeThumbnails(size) {
styles.push(`div#contents.style-scope.ytd-rich-grid-renderer {display:block!important}
ytd-rich-grid-row.style-scope.ytd-rich-grid-renderer {display:inline!important}
ytd-rich-grid-row.style-scope.ytd-rich-grid-renderer > div {display:inline!important;margin:0!important}
ytd-rich-grid-row.style-scope.ytd-rich-grid-renderer > div > ytd-rich-item-renderer,
ytd-rich-item-renderer {
display: inline-block !important;
width: ${size} !important;
contain:none !important;
margin-right: 6px !important;
}`);
}
function use2017Logo() {
styles.push(`
ytd-masthead #logo-icon-container, #contentContainer #logo-icon-container, ytd-topbar-logo-renderer>#logo {
content:var(--logo-2017-light-header) !important;
width: 100px !important;
height: 30px !important;
padding: 0 !important;
}
ytd-masthead[dark] #logo-icon-container, html[dark] #contentContainer #logo-icon-container, ytd-masthead[dark] ytd-topbar-logo-renderer>#logo, html[dark] ytd-topbar-logo-renderer>#logo {
content:var(--logo-2017-dark-header) !important;
width: 100px !important;
height: 30px !important;
}
ytd-topbar-logo-renderer>#logo {
margin-left: -1px;
}
#start>#masthead-logo, #masthead>#masthead-logo {
content:var(--logo-2017-dark-header) !important;
width: 100px !important;
height: 30px !important;
}
html[dark] #start>#masthead-logo, html[dark] #masthead>#masthead-logo {
content:var(--logo-2017-dark-header) !important;
width: 100px !important;
height: 30px !important;
}
#guide-button.ytd-masthead {
margin-right: 7px !important;
top: 1px;
padding: 0 10px;
}
#start.ytd-masthead {
position: relative;
left: 2px;
}
ytd-searchbox.ytd-masthead {
padding: 0 !important;
margin: 0 0 0 38px !important;
}
html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer, html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer:hover {
background-color: #f00 !important
}
[page-subtype="history"] ytd-sub-feed-selector-renderer [aria-checked="true"] #radioLabel.tp-yt-paper-radio-button, [page-subtype="history"] ytd-sub-feed-selector-renderer #radioLabel.tp-yt-paper-radio-button:hover {
border-bottom-color:#f00 !important
}
#country-code.ytd-topbar-logo-renderer {
padding: 0 !important;
margin: 1px 0 0 0.3px !important;
font-size: 11px;
}
html:not([dark]) #guide-section-title.ytd-guide-section-renderer,
html:not([dark]) #guide #header .title {
color: #f00 !important;
}
ytd-mini-guide-entry-renderer[is-active] .guide-icon.ytd-mini-guide-entry-renderer {
color: #f00 !important;
}
html:not([dark]) ytd-guide-collapsible-section-entry-renderer.ytd-guide-section-renderer:not(:first-child):before {
color: #f00 important;
}
`);
}
function redir_shorts() {
function shortsCheck(mutation){
if (location.href.includes('/shorts/')) {
location.replace(location.href.replace('/shorts/', '/watch?v='))
}
}
shortsCheck();
const shortsObserver = new MutationObserver(shortsCheck).observe(document, {subtree: true, childList: true});
}
function use7ktLogo() {
styles.push(`
ytd-masthead #logo-icon-container, #contentContainer #logo-icon-container, ytd-topbar-logo-renderer>#logo {
content:var(--logo-7kt-light-header) !important;
width: 71px !important;
height: 30px !important;
padding: 0 !important;
}
ytd-masthead[dark] #logo-icon-container, html[dark] #contentContainer #logo-icon-container, ytd-masthead[dark] ytd-topbar-logo-renderer>#logo, html[dark] ytd-topbar-logo-renderer>#logo {
content:var(--logo-7kt-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
#start>#masthead-logo, #masthead>#masthead-logo {
content:var(--logo-7kt-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
html[dark] #start>#masthead-logo, html[dark] #masthead>#masthead-logo {
content:var(--logo-7kt-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
#guide-button.ytd-masthead {
margin-right: 8px !important;
top: 1px;
padding: 0 10px;
}
#start.ytd-masthead {
position: relative;
left: 2px;
}
ytd-searchbox.ytd-masthead {
padding: 0 !important;
margin: 0 0 0 38px !important;
}
html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer, html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer:hover {
background-color: var(--oldcolor) !important
}
[page-subtype="history"] ytd-sub-feed-selector-renderer [aria-checked="true"] #radioLabel.tp-yt-paper-radio-button, [page-subtype="history"] ytd-sub-feed-selector-renderer #radioLabel.tp-yt-paper-radio-button:hover {
border-bottom-color:var(--oldcolor)!important
}
#country-code.ytd-topbar-logo-renderer {
padding: 0 !important;
margin: -1px 2px 0 !important;
font-size: 11px;
}
html:not([dark]) #guide-section-title.ytd-guide-section-renderer,
html:not([dark]) #guide #header .title {
color: var(--oldcolor)!important;
}
ytd-mini-guide-entry-renderer[is-active] .guide-icon.ytd-mini-guide-entry-renderer {
color: var(--oldcolor)!important;
}
html:not([dark]) ytd-guide-collapsible-section-entry-renderer.ytd-guide-section-renderer:not(:first-child):before {
color: var(--oldcolor)important;
}
/*OLD RED*/
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer {
background:#e62117
}
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer:hover,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer:hover {
background:#cc181e
}
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer:active,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer:active {
background:#b31217
}
`);
}
function use2015Logo() {
styles.push(`
ytd-masthead #logo-icon-container, #contentContainer #logo-icon-container, ytd-topbar-logo-renderer>#logo {
content:var(--logo-2015-light-header) !important;
width: 71px !important;
height: 30px !important;
padding: 0 !important;
}
ytd-masthead[dark] #logo-icon-container, html[dark] #contentContainer #logo-icon-container, ytd-masthead[dark] ytd-topbar-logo-renderer>#logo, html[dark] ytd-topbar-logo-renderer>#logo {
content:var(--logo-2015-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
#start>#masthead-logo, #masthead>#masthead-logo {
content:var(--logo-2015-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
html[dark] #start>#masthead-logo, html[dark] #masthead>#masthead-logo {
content:var(--logo-2015-dark-header) !important;
width: 71px !important;
height: 30px !important;
}
#guide-button.ytd-masthead {
margin-right: 8px !important;
top: 1px;
padding: 0 10px;
}
#start.ytd-masthead {
position: relative;
left: 2px;
}
ytd-searchbox.ytd-masthead {
padding: 0 !important;
margin: 0 0 0 38px !important;
}
html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer, html:not([dark]) ytd-guide-entry-renderer[active]>#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer:hover {
background-color: var(--oldcolor) !important
}
[page-subtype="history"] ytd-sub-feed-selector-renderer [aria-checked="true"] #radioLabel.tp-yt-paper-radio-button, [page-subtype="history"] ytd-sub-feed-selector-renderer #radioLabel.tp-yt-paper-radio-button:hover {
border-bottom-color:var(--oldcolor)!important
}
#country-code.ytd-topbar-logo-renderer {
padding: 0 !important;
margin: -1px 2px 0 !important;
font-size: 11px;
}
html:not([dark]) #guide-section-title.ytd-guide-section-renderer,
html:not([dark]) #guide #header .title {
color: var(--oldcolor)!important;
}
ytd-mini-guide-entry-renderer[is-active] .guide-icon.ytd-mini-guide-entry-renderer {
color: var(--oldcolor)!important;
}
html:not([dark]) ytd-guide-collapsible-section-entry-renderer.ytd-guide-section-renderer:not(:first-child):before {
color: var(--oldcolor)important;
}
/*OLD RED*/
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer {
background:#e62117
}
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer:hover,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer:hover {
background:#cc181e
}
html #subscribe-button ytd-button-renderer #button.ytd-button-renderer:active,html #subscribe-button tp-yt-paper-button.ytd-subscribe-button-renderer:active {
background:#b31217
}
`);
}
function fixRSD() {
waitForElement('#top-row.ytd-video-secondary-info-renderer').then(function(elm) {
var watchfrag = document.querySelector('#top-row.ytd-video-secondary-info-renderer');
document.querySelector('ytd-video-primary-info-renderer > #container').appendChild(watchfrag);
});
styles.push(`
ytd-app #channel-name.ytd-video-owner-renderer {
top:-16px!important
}
ytd-app ytd-playlist-sidebar-secondary-info-renderer #channel-name.ytd-video-owner-renderer {
top:0!important
}
ytd-app #info ytd-video-primary-info-renderer {
margin-top:10px;
}
ytd-app #info .ryd-tooltip, #info #sentiment.ytd-video-primary-info-renderer {
float:right;
top:-37px!important
}
ytd-app #info .top-level-buttons.ytd-menu-renderer {
border:none
}
ytd-app #info {
top:75px!important
}
ytd-app #info ytd-toggle-button-renderer.style-text[is-icon-button] {
position:unset!important;
}
ytd-app #info ytd-toggle-button-renderer.style-text[is-icon-button]:last-of-type {
left:0
}
`);
}
function patchNonRSD() {
waitForElement('#top-row.ytd-video-secondary-info-renderer').then(function(elm) {
var watchfrag = document.querySelector('#top-row.ytd-video-secondary-info-renderer');
document.querySelector('ytd-video-primary-info-renderer > #container').appendChild(watchfrag);
});
styles.push(`
ytd-app #channel-name.ytd-video-owner-renderer {
top:-16px!important
}
ytd-app ytd-playlist-sidebar-secondary-info-renderer #channel-name.ytd-video-owner-renderer {
top:0!important
}
ytd-app #info ytd-video-primary-info-renderer {
margin-top:10px;
}
ytd-app #info .ryd-tooltip, #info #sentiment.ytd-video-primary-info-renderer {
float:right;
top:-37px!important
}
ytd-app #info .top-level-buttons.ytd-menu-renderer {
border:none
}
ytd-app #info {
top:75px!important
}
ytd-app #info ytd-toggle-button-renderer.style-text[is-icon-button] {
position:unset!important;
}
ytd-app #info ytd-toggle-button-renderer.style-text[is-icon-button]:last-of-type {
left:0
}
`);
}
function enableHomeShelves() {
window.addEventListener("yt-page-data-updated", injectShelvesHp, false);
styles.push(`
ytd-browse[page-subtype='home'] ytd-rich-grid-renderer {
display: none !important;
}
ytd-browse[page-subtype='home'] #contents.ytd-item-section-renderer > ytd-shelf-renderer.ytd-item-section-renderer:first-child {
margin-top: 17px;
padding-bottom: 3px;
}
ytd-browse[page-subtype='home'] #contents.ytd-shelf-renderer {
margin-top: 5px !important;
}
ytd-browse[page-subtype='home'] ytd-thumbnail #thumbnail.ytd-thumbnail {
margin-left: 0;
}
ytd-browse[page-subtype='home'] ytd-section-list-renderer {
padding: 0 !important;
}
ytd-browse[page-subtype='home'] #contents.ytd-item-section-renderer {
padding: 0 16px;
}
ytd-browse[page-subtype='home'] #scroll-container.yt-horizontal-list-renderer ytd-thumbnail-overlay-time-status-renderer {
margin-top: 5px !important;
}
ytd-browse[page-subtype='home'] ytd-shelf-renderer img.yt-img-shadow {
max-height: var(--ytd-grid-thumbnail_-_height);
}`);
}
function hideSearchBlocks() {
styles.push(`
ytd-two-column-search-results-renderer ytd-shelf-renderer.style-scope.ytd-item-section-renderer, ytd-two-column-search-results-renderer ytd-horizontal-card-list-renderer.style-scope.ytd-item-section-renderer {
display: none!important
}`);
}
async function returnDislike() {
if (window.location.pathname != "/watch")
return;
const menu = await waitForElement("#menu-container");
const likeButton = document.querySelector("#info #segmented-like-button");
// reconstruct dislike if needed
const dislikeButton = document.querySelector("#info #segmented-dislike-button");
var dislikeText = dislikeButton.querySelector("#text");
if (!dislikeText) {
dislikeText = document.createElement("yt-formatted-string");
dislikeText.className = "style-scope ytd-toggle-button-renderer style-text";
dislikeText.id = "text";
dislikeText.removeAttribute("is-empty");
dislikeButton.querySelector("button").appendChild(dislikeText);
}
const videoId = new URL(window.location.href).searchParams.get("v");
const apiResponse = await fetch(`https://returnyoutubedislikeapi.com/votes?videoId=${videoId}`);
const apiResult = await apiResponse.json();
if (!apiResult || "traceId" in apiResponse)
return;
const { dislikes } = apiResult;
const likes = parseInt(likeButton.querySelector("#text").getAttribute("aria-label").match(/\d/g).join(""));
dislikeText.innerText = dislikes.toLocaleString();
const rateBar = document.getElementById("return-youtube-dislike-bar-container");
const widthPx = likeButton.clientWidth + dislikeButton.clientWidth + 8;
const widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 0;
dislikeButton.addEventListener("click", function() {
const btnText = this.querySelector("#text");
let btnCount = parseInt(btnText.innerText.match(/\d/g).join(""));
btnCount += this.firstChild.classList.contains("style-default-active") ? 1 : -1;
btnText.innerText = btnCount.toLocaleString();
});
if (!rateBar) {
menu.insertAdjacentHTML("beforeend", `