Mercurial > ec-userscripts
changeset 117:d9dc190bccaf
Undo combining fixes into single script per site
author | nanaya <me@nanaya.net> |
---|---|
date | Sun, 15 Jan 2023 23:49:35 +0900 |
parents | 0e108a9dc6d7 |
children | 8de2d53a4cb1 |
files | cuffs-hulotte-popup.user.js jiku-chu-direct-link.user.js mandarake-direct-link.user.js medium-popup-disable.user.js melonbooks-unlazy.user.js pixiv-direct-external-link.user.js pixiv-fanbox-unlazy.user.js rakuten-books-direct-search.user.js soranews-image.user.js tweetdeck-large-image.user.js youtube-no-shorts.user.js |
diffstat | 11 files changed, 232 insertions(+), 276 deletions(-) [+] |
line wrap: on
line diff
--- 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(); +}
--- 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);
--- 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);
--- 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);
--- 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);
--- 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);
--- 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);
--- 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();
--- 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();
--- 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();
--- 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=');