# HG changeset patch # User nanaya # Date 1673794175 -32400 # Node ID d9dc190bccaf41d7b30b0784b828351dba6c8536 # Parent 0e108a9dc6d74cbefdb87261e021d42b3b534d41 Undo combining fixes into single script per site diff -r 0e108a9dc6d7 -r d9dc190bccaf cuffs-hulotte-popup.user.js --- a/cuffs-hulotte-popup.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/cuffs-hulotte-popup.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -14,35 +14,31 @@ 'use strict'; /* global jQuery, stopload */ -function alwaysConsent () { - const $ = jQuery; - const rules = []; - let i; - let styleEl; - - if (document.querySelector('body > #mainContent') != null) { - rules.push('body > :not(#mainContent) { display: none !important; }'); - } - - rules.push('#load_bg { display: none !important; }'); - rules.push('body > .modal { display: none !important; }'); - rules.push('body > div[style*="position: fixed"] { display: none !important; }'); +const $ = jQuery; +const rules = []; +let i; +let styleEl; - for (i = 0; i < rules.length; i++) { - styleEl = document.createElement('style'); - document.head.appendChild(styleEl); - styleEl.sheet.insertRule(rules[i], 0); - } - - $(function () { - $('.cboxElement').removeClass('cboxElement'); - }); - - // force remove modal - $.cookie('modal', 'off'); - if (typeof stopload === 'function') { - stopload(); - } +if (document.querySelector('body > #mainContent') != null) { + rules.push('body > :not(#mainContent) { display: none !important; }'); } -alwaysConsent(); +rules.push('#load_bg { display: none !important; }'); +rules.push('body > .modal { display: none !important; }'); +rules.push('body > div[style*="position: fixed"] { display: none !important; }'); + +for (i = 0; i < rules.length; i++) { + styleEl = document.createElement('style'); + document.head.appendChild(styleEl); + styleEl.sheet.insertRule(rules[i], 0); +} + +$(function () { + $('.cboxElement').removeClass('cboxElement'); +}); + +// force remove modal +$.cookie('modal', 'off'); +if (typeof stopload === 'function') { + stopload(); +} diff -r 0e108a9dc6d7 -r d9dc190bccaf jiku-chu-direct-link.user.js --- a/jiku-chu-direct-link.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/jiku-chu-direct-link.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -12,17 +12,13 @@ 'use strict'; -function directLink () { - const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]"); - const removeOnClick = function (el) { - const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1'); - const url = `/products/detail.php?product_id=${productId}`; +const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]"); +const removeOnClick = function (el) { + const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1'); + const url = `/products/detail.php?product_id=${productId}`; - el.setAttribute('href', url); - el.setAttribute('onclick', ''); - }; + el.setAttribute('href', url); + el.setAttribute('onclick', ''); +}; - Array.prototype.forEach.call(links, removeOnClick); -} - -directLink(); +Array.prototype.forEach.call(links, removeOnClick); diff -r 0e108a9dc6d7 -r d9dc190bccaf mandarake-direct-link.user.js --- a/mandarake-direct-link.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/mandarake-direct-link.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -13,47 +13,43 @@ 'use strict'; -function directLink () { - const r18ConfirmLink = '#adult_confirm'; - function fixR18Link (link) { - if (!(link instanceof window.HTMLAnchorElement) || link.getAttribute('href') !== r18ConfirmLink) return; - - link.setAttribute('href', `/order/detailPage/item?itemCode=${link.id}`); - link.removeAttribute('class'); - } +const r18ConfirmLink = '#adult_confirm'; +function fixR18Link (link) { + if (!(link instanceof window.HTMLAnchorElement) || link.getAttribute('href') !== r18ConfirmLink) return; - function removeR18Mark (node) { - if (node.classList.contains('r18mark')) { - node.remove(); - return true; - } + link.setAttribute('href', `/order/detailPage/item?itemCode=${link.id}`); + link.removeAttribute('class'); +} - for (const mark of node.querySelectorAll('.r18mark')) { - mark.remove(); - } +function removeR18Mark (node) { + if (node.classList.contains('r18mark')) { + node.remove(); + return true; } - function run (node) { - if (!(node instanceof window.HTMLElement)) return; - if (removeR18Mark(node)) return; + for (const mark of node.querySelectorAll('.r18mark')) { + mark.remove(); + } +} + +function run (node) { + if (!(node instanceof window.HTMLElement)) return; + if (removeR18Mark(node)) return; - fixR18Link(node); - for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) { - fixR18Link(link); + fixR18Link(node); + for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) { + fixR18Link(link); + } +} + +function onMutate (mutations) { + for (const mutation of mutations) { + for (const node of mutation.addedNodes) { + run(node); } } - - function onMutate (mutations) { - for (const mutation of mutations) { - for (const node of mutation.addedNodes) { - run(node); - } - } - } - - const observer = new window.MutationObserver(onMutate); - observer.observe(document, { childList: true, subtree: true }); - run(document.body); } -directLink(); +const observer = new window.MutationObserver(onMutate); +observer.observe(document, { childList: true, subtree: true }); +run(document.body); diff -r 0e108a9dc6d7 -r d9dc190bccaf medium-popup-disable.user.js --- a/medium-popup-disable.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/medium-popup-disable.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -14,15 +14,11 @@ 'use strict'; -function removeHighlightPopup () { - const popups = document.getElementsByClassName('highlightMenu'); - const killPopup = function (popup) { - popup.style.display = 'none'; - }; - const killPopups = function () { - Array.prototype.forEach.call(popups, killPopup); - }; - document.addEventListener('click', killPopups); -} - -removeHighlightPopup(); +const popups = document.getElementsByClassName('highlightMenu'); +const killPopup = function (popup) { + popup.style.display = 'none'; +}; +const killPopups = function () { + Array.prototype.forEach.call(popups, killPopup); +}; +document.addEventListener('click', killPopups); diff -r 0e108a9dc6d7 -r d9dc190bccaf melonbooks-unlazy.user.js --- a/melonbooks-unlazy.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/melonbooks-unlazy.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -12,39 +12,35 @@ 'use strict'; -function unlazy () { - function fix (image) { - if (!image.classList.contains('lazyload')) return; +function fix (image) { + if (!image.classList.contains('lazyload')) return; + + const src = image.dataset.src; - const src = image.dataset.src; + if (src == null || src === '') return; - if (src == null || src === '') return; + image.classList.remove('lazyload'); + image.src = image.dataset.src; + delete image.dataset.src; +} - image.classList.remove('lazyload'); - image.src = image.dataset.src; - delete image.dataset.src; - } +function run (node) { + if (!(node instanceof window.HTMLElement)) return; - function run (node) { - if (!(node instanceof window.HTMLElement)) return; + fix(node); + for (const image of node.querySelectorAll('.lazyload')) { + fix(image); + } +} - fix(node); - for (const image of node.querySelectorAll('.lazyload')) { - fix(image); +function onMutate (mutations) { + for (const mutation of mutations) { + for (const node of mutation.addedNodes) { + run(node); } } - - function onMutate (mutations) { - for (const mutation of mutations) { - for (const node of mutation.addedNodes) { - run(node); - } - } - } - - const observer = new window.MutationObserver(onMutate); - observer.observe(document, { childList: true, subtree: true }); - run(document.body); } -unlazy(); +const observer = new window.MutationObserver(onMutate); +observer.observe(document, { childList: true, subtree: true }); +run(document.body); diff -r 0e108a9dc6d7 -r d9dc190bccaf pixiv-direct-external-link.user.js --- a/pixiv-direct-external-link.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/pixiv-direct-external-link.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -12,16 +12,12 @@ 'use strict'; /* global $ */ -function directLink () { - const fixLink = function (_i, el) { - const $el = $(el); - const url = decodeURIComponent($el.attr('href').replace(/^\/?jump.php\?/, '')); +const fixLink = function (_i, el) { + const $el = $(el); + const url = decodeURIComponent($el.attr('href').replace(/^\/?jump.php\?/, '')); - $el.attr('href', url); - }; + $el.attr('href', url); +}; - $("[href^='jump.php?']").each(fixLink); - $("[href^='/jump.php?']").each(fixLink); -} - -directLink(); +$("[href^='jump.php?']").each(fixLink); +$("[href^='/jump.php?']").each(fixLink); diff -r 0e108a9dc6d7 -r d9dc190bccaf pixiv-fanbox-unlazy.user.js --- a/pixiv-fanbox-unlazy.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/pixiv-fanbox-unlazy.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -12,54 +12,50 @@ 'use strict'; -function unlazy () { - const imageUrlPrefix = 'https://downloads.fanbox.cc/images/post/'; +const imageUrlPrefix = 'https://downloads.fanbox.cc/images/post/'; + +function disableEventLink (event) { + event.stopPropagation(); +} - function disableEventLink (event) { - event.stopPropagation(); +function fix (link) { + const href = link.href; + + // basic sanity check + if (typeof href !== 'string' || !href.startsWith(imageUrlPrefix)) { + return; } - function fix (link) { - const href = link.href; + // don't run again if already run on passed link + if (link._ecUserscript) { + return; + } + link._ecUserscript = true; - // basic sanity check - if (typeof href !== 'string' || !href.startsWith(imageUrlPrefix)) { - return; - } - - // don't run again if already run on passed link - if (link._ecUserscript) { - return; - } - link._ecUserscript = true; + link.addEventListener('click', disableEventLink); + const image = document.createElement('img'); + image.style.width = '100%'; + image.src = href; + link.replaceChildren(image); +} - link.addEventListener('click', disableEventLink); - const image = document.createElement('img'); - image.style.width = '100%'; - image.src = href; - link.replaceChildren(image); - } +function run (node) { + if (!(node instanceof window.HTMLElement)) return; - function run (node) { - if (!(node instanceof window.HTMLElement)) return; + fix(node); + for (const link of node.querySelectorAll(`[href^="${imageUrlPrefix}"]`)) { + fix(link); + } +} - fix(node); - for (const link of node.querySelectorAll(`[href^="${imageUrlPrefix}"]`)) { - fix(link); +function onMutate (mutations) { + for (const mutation of mutations) { + for (const node of mutation.addedNodes) { + run(node); } } - - function onMutate (mutations) { - for (const mutation of mutations) { - for (const node of mutation.addedNodes) { - run(node); - } - } - } - - const observer = new window.MutationObserver(onMutate); - observer.observe(document, { childList: true, subtree: true }); - run(document.body); } -unlazy(); +const observer = new window.MutationObserver(onMutate); +observer.observe(document, { childList: true, subtree: true }); +run(document.body); diff -r 0e108a9dc6d7 -r d9dc190bccaf rakuten-books-direct-search.user.js --- a/rakuten-books-direct-search.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/rakuten-books-direct-search.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -15,14 +15,10 @@ 'use strict'; /* global jQuery */ -function noTrackSearch () { - const $ = jQuery; - const $form = $("form[name='srchFrm']"); +const $ = jQuery; +const $form = $("form[name='srchFrm']"); - if (!$form.length) { return; } - +if ($form.length > 0) { const searchUrl = $form.find("input[name='R2']").attr('value'); $form.attr('action', searchUrl); } - -noTrackSearch(); diff -r 0e108a9dc6d7 -r d9dc190bccaf soranews-image.user.js --- a/soranews-image.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/soranews-image.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -11,47 +11,43 @@ 'use strict'; -function unlazy () { - const fix = function (image) { - // basic sanity check - if (!image.classList.contains('lazy')) { - return; - } +const fix = function (image) { + // basic sanity check + if (!image.classList.contains('lazy')) { + return; + } - image.classList.remove('lazy'); - image.removeAttribute('src'); - image.setAttribute('srcset', image.dataset.scoSrcset); - }; + image.classList.remove('lazy'); + image.removeAttribute('src'); + image.setAttribute('srcset', image.dataset.scoSrcset); +}; - // loop through passed nodes (or body if called without arguments) - const run = function (nodes) { - if (nodes == null) { - nodes = [document.body]; - } - - for (let i = 0; i < nodes.length; i++) { - // find all the images inside (and self) - const images = [nodes[i], ...nodes[i].querySelectorAll('.lazy')]; +// loop through passed nodes (or body if called without arguments) +const run = function (nodes) { + if (nodes == null) { + nodes = [document.body]; + } - for (let j = 0; j < images.length; j++) { - fix(images[j]); - } - } - }; + for (let i = 0; i < nodes.length; i++) { + // find all the images inside (and self) + const images = [nodes[i], ...nodes[i].querySelectorAll('.lazy')]; - const onMutate = function (mutations) { - for (const mutation in mutations) { - run(mutation.addedNodes); + for (let j = 0; j < images.length; j++) { + fix(images[j]); } - }; - - // the observer - const observer = new window.MutationObserver(onMutate); + } +}; - // start the observer - observer.observe(document, { childList: true, subtree: true }); - // initial run on existing document - run(); -} +const onMutate = function (mutations) { + for (const mutation in mutations) { + run(mutation.addedNodes); + } +}; -unlazy(); +// the observer +const observer = new window.MutationObserver(onMutate); + +// start the observer +observer.observe(document, { childList: true, subtree: true }); +// initial run on existing document +run(); diff -r 0e108a9dc6d7 -r d9dc190bccaf tweetdeck-large-image.user.js --- a/tweetdeck-large-image.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/tweetdeck-large-image.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -11,77 +11,73 @@ 'use strict'; -function origLink () { - const fix = function (link) { - // basic sanity check - if (!link.classList.contains('js-media-image-link')) { - return; - } +const fix = function (link) { + // basic sanity check + if (!link.classList.contains('js-media-image-link')) { + return; + } - // don't run again if already run on passed link - if (link._ecUserscript) { - return; - } - link._ecUserscript = true; + // don't run again if already run on passed link + if (link._ecUserscript) { + return; + } + link._ecUserscript = true; - const image = link.querySelector('.media-img'); - let url; + const image = link.querySelector('.media-img'); + let url; - // sometimes the image is just background image of the link. - // strip all query strings and original :size suffix - if (image == null) { - url = window.getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, '$2'); - } else { - url = image.src; - } + // sometimes the image is just background image of the link. + // strip all query strings and original :size suffix + if (image == null) { + url = window.getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, '$2'); + } else { + url = image.src; + } - const parsedUrl = new URL(url); + const parsedUrl = new URL(url); - if (parsedUrl.searchParams.get('name') == null) { - url = url.replace(/(\..+:).+/, '$1orig'); - } else { - if (parsedUrl.pathname.match(/\.[^.]+$/) !== null) { - parsedUrl.searchParams.delete('format'); - } - parsedUrl.searchParams.set('name', 'orig'); - url = parsedUrl.href; + if (parsedUrl.searchParams.get('name') == null) { + url = url.replace(/(\..+:).+/, '$1orig'); + } else { + if (parsedUrl.pathname.match(/\.[^.]+$/) !== null) { + parsedUrl.searchParams.delete('format'); } + parsedUrl.searchParams.set('name', 'orig'); + url = parsedUrl.href; + } - link.setAttribute('href', url); - }; + link.setAttribute('href', url); +}; - // loop through passed nodes (or body if called without arguments) - const run = function (nodes) { - if (nodes == null) { - nodes = [document.body]; - } +// loop through passed nodes (or body if called without arguments) +const run = function (nodes) { + if (nodes == null) { + nodes = [document.body]; + } - for (let i = 0; i < nodes.length; i++) { - // first try fixing itself - fix(nodes[i]); + for (let i = 0; i < nodes.length; i++) { + // first try fixing itself + fix(nodes[i]); - // and then find all the links inside - const links = nodes[i].querySelectorAll('.js-media-image-link'); + // and then find all the links inside + const links = nodes[i].querySelectorAll('.js-media-image-link'); - for (let j = 0; j < links.length; j++) { - fix(links[j]); - } - } - }; - - const onMutate = function (mutations) { - for (const mutation in mutations) { - run(mutation.addedNodes); + for (let j = 0; j < links.length; j++) { + fix(links[j]); } - }; - - // the observer - const observer = new window.MutationObserver(onMutate); + } +}; - // start the observer - observer.observe(document, { childList: true, subtree: true }); - // initial run on existing document - run(); -} +const onMutate = function (mutations) { + for (const mutation in mutations) { + run(mutation.addedNodes); + } +}; -origLink(); +// the observer +const observer = new window.MutationObserver(onMutate); + +// start the observer +observer.observe(document, { childList: true, subtree: true }); +// initial run on existing document +run(); diff -r 0e108a9dc6d7 -r d9dc190bccaf youtube-no-shorts.user.js --- a/youtube-no-shorts.user.js Sun Jan 15 23:46:56 2023 +0900 +++ b/youtube-no-shorts.user.js Sun Jan 15 23:49:35 2023 +0900 @@ -12,9 +12,5 @@ 'use strict'; // Source: https://gist.github.com/Ultrawipf/7af006d1b8f75eddd3222d1053c3a243 -function shortDirect () { - // From https://www.youtube.com/shorts/xxxx to https://www.youtube.com/watch?v=xxxx - window.location = window.location.href.replace('youtube.com/shorts/', 'youtube.com/watch?v='); -} - -shortDirect(); +// From https://www.youtube.com/shorts/xxxx to https://www.youtube.com/watch?v=xxxx +window.location = window.location.href.replace('youtube.com/shorts/', 'youtube.com/watch?v=');