Browse Source

fix layout changes late 2021

Mike L 3 years ago
parent
commit
25699e7a47
2 changed files with 4 additions and 4 deletions
  1. 2 2
      dist/webshot.js
  2. 2 2
      src/webshot.ts

+ 2 - 2
dist/webshot.js

@@ -86,7 +86,7 @@ class Webshot extends CallableInstance {
                     ]))
                     ]))
                         .then(() => page.addStyleTag({
                         .then(() => page.addStyleTag({
                         content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +
                         content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +
-                            '[data-testid="caret"],[role="group"],[data-testid="tweet"]+*>[class*=" "]+div:nth-last-child(2){display:none}',
+                            '[data-testid="caret"],[role="group"],[data-testid="tweet"] [class*=" "]+:last-child>*+[class*=" "]~div{display:none}',
                     }))
                     }))
                         .then(() => page.addStyleTag({
                         .then(() => page.addStyleTag({
                         content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
                         content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
@@ -122,7 +122,7 @@ class Webshot extends CallableInstance {
                             throw new puppeteer.errors.TimeoutError();
                             throw new puppeteer.errors.TimeoutError();
                         return handle.evaluate(div => {
                         return handle.evaluate(div => {
                             try {
                             try {
-                                const selector = '[data-testid="tweet"]>:nth-child(2)>:first-child a';
+                                const selector = '[data-testid="tweet"] :nth-child(2)>:first-child a';
                                 const getProfileUrl = () => (div.querySelector(selector) || { href: '' }).href;
                                 const getProfileUrl = () => (div.querySelector(selector) || { href: '' }).href;
                                 const ownerProfileUrl = getProfileUrl();
                                 const ownerProfileUrl = getProfileUrl();
                                 while (div = div.previousElementSibling) {
                                 while (div = div.previousElementSibling) {

+ 2 - 2
src/webshot.ts

@@ -112,7 +112,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
             // hide header, "more options" button, like and retweet count
             // hide header, "more options" button, like and retweet count
             .then(() => page.addStyleTag({
             .then(() => page.addStyleTag({
               content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +
               content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +
-                '[data-testid="caret"],[role="group"],[data-testid="tweet"]+*>[class*=" "]+div:nth-last-child(2){display:none}',
+                '[data-testid="caret"],[role="group"],[data-testid="tweet"] [class*=" "]+:last-child>*+[class*=" "]~div{display:none}',
             }))
             }))
             .then(() => page.addStyleTag({
             .then(() => page.addStyleTag({
               content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
               content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
@@ -151,7 +151,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
               if (handle === null) throw new puppeteer.errors.TimeoutError();
               if (handle === null) throw new puppeteer.errors.TimeoutError();
               return handle.evaluate(div => {
               return handle.evaluate(div => {
                 try {
                 try {
-                  const selector = '[data-testid="tweet"]>:nth-child(2)>:first-child a';
+                  const selector = '[data-testid="tweet"] :nth-child(2)>:first-child a';
                   const getProfileUrl = () => (div.querySelector<HTMLAnchorElement>(selector) || {href: ''}).href;
                   const getProfileUrl = () => (div.querySelector<HTMLAnchorElement>(selector) || {href: ''}).href;
                   const ownerProfileUrl = getProfileUrl();
                   const ownerProfileUrl = getProfileUrl();
                   // eslint-disable-next-line no-cond-assign
                   // eslint-disable-next-line no-cond-assign