diff tweetdeck-large-image.user.js @ 108:2c4470b73ad9

Switch to semistandard No more `;` at the start of line.
author nanaya <me@nanaya.net>
date Sun, 15 Jan 2023 23:24:03 +0900
parents 9c8cde985caf
children ef21ef445fc6
line wrap: on
line diff
--- a/tweetdeck-large-image.user.js	Sun Jan 15 23:15:45 2023 +0900
+++ b/tweetdeck-large-image.user.js	Sun Jan 15 23:24:03 2023 +0900
@@ -9,77 +9,77 @@
 // @downloadURL  https://hg.myconan.net/ec-userscripts/raw-file/tip/tweetdeck-large-image.user.js
 // ==/UserScript==
 
-;(function () {
-  'use strict'
+(function () {
+  'use strict';
 
   const fix = function (link) {
     // basic sanity check
     if (!link.classList.contains('js-media-image-link')) {
-      return
+      return;
     }
 
     // don't run again if already run on passed link
     if (link._ecUserscript) {
-      return
+      return;
     }
-    link._ecUserscript = true
+    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')
+      url = window.getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, '$2');
     } else {
-      url = image.src
+      url = image.src;
     }
 
-    const parsedUrl = new URL(url)
+    const parsedUrl = new URL(url);
 
     if (parsedUrl.searchParams.get('name') == null) {
-      url = url.replace(/(\..+:).+/, '$1orig')
+      url = url.replace(/(\..+:).+/, '$1orig');
     } else {
       if (parsedUrl.pathname.match(/\.[^.]+$/) !== null) {
-        parsedUrl.searchParams.delete('format')
+        parsedUrl.searchParams.delete('format');
       }
-      parsedUrl.searchParams.set('name', 'orig')
-      url = parsedUrl.href
+      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]
+      nodes = [document.body];
     }
 
     for (let i = 0; i < nodes.length; i++) {
       // first try fixing itself
-      fix(nodes[i])
+      fix(nodes[i]);
 
       // and then find all the links inside
-      const links = nodes[i].querySelectorAll('.js-media-image-link')
+      const links = nodes[i].querySelectorAll('.js-media-image-link');
 
       for (let j = 0; j < links.length; j++) {
-        fix(links[j])
+        fix(links[j]);
       }
     }
-  }
+  };
 
   const onMutate = function (mutations) {
     for (const mutation in mutations) {
-      run(mutation.addedNodes)
+      run(mutation.addedNodes);
     }
-  }
+  };
 
   // the observer
-  const observer = new window.MutationObserver(onMutate)
+  const observer = new window.MutationObserver(onMutate);
 
   // start the observer
-  observer.observe(document, { childList: true, subtree: true })
+  observer.observe(document, { childList: true, subtree: true });
   // initial run on existing document
-  run()
-}).call()
+  run();
+}).call();