From 0c7729e783b7a3bb571def19d0c0b81669882d89 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Wed, 28 May 2014 17:10:49 +0200 Subject: [PATCH] [TwitterBridge] clean links --- bridges/TwitterBridge.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 5a9b7db7..5f5aa81e 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -37,6 +37,18 @@ class TwitterBridge extends BridgeAbstract{ $item->id = $tweet->getAttribute('data-tweet-id'); // get TweetID $item->uri = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); // get tweet link $item->timestamp = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp + // processing content links + foreach($tweet->find('a') as $link) { + if($link->hasAttribute('data-expanded-url') ) { + $link->href = $link->getAttribute('data-expanded-url'); + } + $link->removeAttribute('data-expanded-url'); + $link->removeAttribute('data-query-source'); + $link->removeAttribute('rel'); + $link->removeAttribute('class'); + $link->removeAttribute('target'); + $link->removeAttribute('title'); + } $item->content = str_replace('href="/', 'href="https://twitter.com/', strip_tags($tweet->find('p.js-tweet-text', 0)->innertext, '')); // extract tweet text $item->title = $item->fullname . ' (@'. $item->username . ') | ' . $item->content; $this->items[] = $item;