diff --git a/changelog.md b/changelog.md index 4c2823b..6b97dea 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.1.5] - 2023-07-01 + +### Fixed + +- 🔥 Fix error finding tweets. + ## [2.1.4] - 2022-01-03 ### Fixed @@ -85,7 +91,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Automatically print when replies have finished loading. - Hide promoted tweets. -[Unreleased]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.4...HEAD +[Unreleased]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.5...HEAD +[2.1.5]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.4...v2.1.5 [2.1.4]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.3...v2.1.4 [2.1.3]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.2...v2.1.3 [2.1.2]: https://github.com/tannerhodges/twitter-print-styles/compare/v2.1.1...v2.1.2 diff --git a/package-lock.json b/package-lock.json index 45226c0..9c8ac72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twitter-print-styles", - "version": "2.1.4", + "version": "2.1.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "twitter-print-styles", - "version": "2.1.4", + "version": "2.1.5", "license": "MIT", "dependencies": { "eslint": "^7.32.0", diff --git a/package.json b/package.json index 1d02ba3..9cc819b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "twitter-print-styles", - "version": "2.1.4", + "version": "2.1.5", "description": "Chrome extension for adding simple print styles to save Twitter threads as PDFs.", "keywords": [ "chrome", diff --git a/src/content.js b/src/content.js index 538fe4c..6d2766f 100644 --- a/src/content.js +++ b/src/content.js @@ -105,7 +105,7 @@ function getAllCSS(doc = document) { .map(rule => rule.cssText) .join(''); } catch (e) { - console.log('Access to stylesheet %s is denied. Ignoring...', styleSheet.href); + console.log('[twitter-print-styles] Access to stylesheet %s is denied. Ignoring...', styleSheet.href); } }) .filter(Boolean) @@ -164,7 +164,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => { // Multiple clicks cancels out any running tasks. if (running) { - console.log('Cancelling current task...'); + console.log('[twitter-print-styles] Cancelling current task...'); keepRunning = false; return; } @@ -185,9 +185,10 @@ Dev Tools > More Tools > Rendering > Emulate CSS media type // NOTE: While several views have "Timelines", this is // only expected to work on _Tweets_ & _Threads_. const timeline = document.querySelector('[data-testid="primaryColumn"] [role="region"] > div'); + console.log('[twitter-print-styles] = timeline', timeline); if (!timeline) { - console.log('Could not find Twitter timeline.'); + console.log('[twitter-print-styles] Could not find Twitter timeline.'); return; } @@ -195,7 +196,8 @@ Dev Tools > More Tools > Rendering > Emulate CSS media type keepRunning = true; // Find the tweets. - const container = timeline.firstElementChild; + const container = timeline.querySelector('[style*="position: relative"]'); + console.log('[twitter-print-styles] container =', container); // Make sure we're actually on the first one. window.scrollTo(0, 0); @@ -205,6 +207,7 @@ Dev Tools > More Tools > Rendering > Emulate CSS media type let tweet = container.firstElementChild; let count = 0; let error = false; + console.log('[twitter-print-styles] tweet = ', tweet); // Since Twitter only shows a few tweets in the DOM at a time, we need to // cache them in a variable so we can print them all together. @@ -241,7 +244,7 @@ Dev Tools > More Tools > Rendering > Emulate CSS media type // Increment tweet count. count += 1; - console.log(`Tweet #${count}`, tweet); + console.log(`[twitter-print-styles] Tweet #${count}`, tweet); // Scroll tweet to the top of the screen (to trigger Twitter's "load more" action). tweet.scrollIntoView(true); @@ -257,8 +260,7 @@ Dev Tools > More Tools > Rendering > Emulate CSS media type tweet = await waitUntil(async (resolve) => { const nextTweet = tweet.nextElementSibling; - - console.log('Finding next tweet...'); + console.log('[twitter-print-styles] Finding next tweet...', nextTweet); // If we fail to find a tweet within 10 seconds, something's probably gone wrong. // Assume the worst and abort. @@ -282,18 +284,18 @@ https://github.com/tannerhodges/twitter-print-styles/issues`); } if (!nextTweet) { - console.log('Tweet not found.', tweet); + console.log('[twitter-print-styles] Tweet not found.', tweet); return; } if (isLastTweet(nextTweet)) { - console.log('--- THE END ---'); + console.log('[twitter-print-styles] --- THE END ---'); resolve(false); return; } if (isMoreReplies(nextTweet)) { - console.log('Loading more replies...'); + console.log('[twitter-print-styles] Loading more replies...'); const moreReplies = nextTweet.querySelector('[role="button"]'); moreReplies.click(); return; @@ -315,7 +317,7 @@ https://github.com/tannerhodges/twitter-print-styles/issues`); return; } - console.log('PRINT'); + console.log('[twitter-print-styles] PRINT'); // Copy the Twitter timeline into a new window. const clone = document.querySelector('[data-testid="primaryColumn"]').cloneNode(true); diff --git a/src/manifest.json b/src/manifest.json index 5e6d65d..927e541 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Twitter Print Styles", - "version": "2.1.4", + "version": "2.1.5", "description": "Simple print styles for saving Twitter threads as PDFs.", "icons": { "16": "icon-16.png",