diff surugaya-fixes.user.js @ 109:ef21ef445fc6

Cleanups - wrap everything in function and call them last - fix namespace and update url
author nanaya <me@nanaya.net>
date Sun, 15 Jan 2023 23:33:41 +0900
parents 2c4470b73ad9
children
line wrap: on
line diff
--- a/surugaya-fixes.user.js	Sun Jan 15 23:24:03 2023 +0900
+++ b/surugaya-fixes.user.js	Sun Jan 15 23:33:41 2023 +0900
@@ -1,18 +1,18 @@
 // ==UserScript==
 // @name         suruga-ya fixes
-// @namespace    https://myconan.net
+// @namespace    https://nanaya.net
 // @version      2.0.2
 // @description  Show all products with fast image
 // @author       nanaya
 // @match        https://www.suruga-ya.jp/*
 // @grant        none
-// @downloadURL  https://hg.myconan.net/ec-userscripts/raw-file/tip/surugaya-fixes.user.js
+// @downloadURL  https://hg.nanaya.net/ec-userscripts/raw-file/tip/surugaya-fixes.user.js
 // ==/UserScript==
 
 'use strict';
 
 // always inject adult consent cookie
-(function () {
+function alwaysConsent () {
   const hasAdultCookie = document.cookie.split('; ').includes('adult=1');
   if (!hasAdultCookie) {
     const d = new Date();
@@ -20,10 +20,10 @@
     document.cookie = `adult=1; expires=${d.toGMTString()}; path=/`;
     window.location.reload();
   }
-})();
+}
 
 // skip loading image through php which seems to take forever
-(function () {
+function directImage () {
   const itemImageRegexp = /photo\.php\?shinaban=([0-9A-Z]+)/;
   function fix (image) {
     const origSrc = image.getAttribute('src');
@@ -60,4 +60,7 @@
   const observer = new window.MutationObserver(onMutate);
   observer.observe(document, { childList: true, subtree: true });
   run(document.body);
-})();
+}
+
+alwaysConsent();
+directImage();