Selaa lähdekoodia

fix instagram layout update yesterday

Mike L 3 vuotta sitten
vanhempi
commit
c6e1cbbd3f
2 muutettua tiedostoa jossa 13 lisäystä ja 13 poistoa
  1. 6 6
      dist/webshot.js
  2. 7 7
      src/webshot.ts

+ 6 - 6
dist/webshot.js

@@ -105,15 +105,15 @@ class Webshot extends CallableInstance {
                         content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
                     }))
                         .then(() => page.evaluate(() => {
-                        let time;
-                        time = document.querySelector('div>div>time');
+                        let time = document.querySelector('div>div>time');
                         if (time)
                             time.parentElement.parentElement.style.display = 'none';
-                        time = document.querySelector('main section~div>a>time');
-                        if (time) {
+                        const a = document.querySelector(`main section~div a[href="${new URL(location.href).pathname}"]`);
+                        if (a) {
+                            time = a.querySelector('time');
                             time.innerHTML = time.title + ' ' + new Date(time.dateTime).toLocaleTimeString().slice(0, -3);
-                            time.parentElement.parentElement.style.margin = '-24px 2px 12px';
-                            const element = time.parentElement.parentElement.nextElementSibling;
+                            a.parentElement.style.margin = '-24px 2px 12px';
+                            const element = a.parentElement.nextElementSibling;
                             if (element)
                                 element.style.display = 'none';
                         }

+ 7 - 7
src/webshot.ts

@@ -143,16 +143,16 @@ class Webshot extends CallableInstance<[LazyMediaItem[], (...args) => void, numb
             .then(() => page.addStyleTag({
               content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
             }))
-            // display absolute date and time and remove "comment limited" notice
+            // display absolute date and time, remove time element in thread and remove "comment limited" notice
             .then(() => page.evaluate(() => {
-              let time: HTMLTimeElement;
-              time = document.querySelector('div>div>time');
+              let time = document.querySelector<HTMLTimeElement>('div>div>time');
               if (time) time.parentElement.parentElement.style.display = 'none';
-              time = document.querySelector('main section~div>a>time');
-              if (time) {
+              const a = document.querySelector(`main section~div a[href="${new URL(location.href).pathname}"]`);
+              if (a) {
+                time = a.querySelector('time');
                 time.innerHTML = time.title + ' ' + new Date(time.dateTime).toLocaleTimeString().slice(0, -3);
-                time.parentElement.parentElement.style.margin = '-24px 2px 12px';
-                const element = time.parentElement.parentElement.nextElementSibling as HTMLElement;
+                a.parentElement.style.margin = '-24px 2px 12px';
+                const element = a.parentElement.nextElementSibling as HTMLElement;
                 if (element) element.style.display = 'none';
               }
             }))