File tree Expand file tree Collapse file tree 3 files changed +31
-193
lines changed Expand file tree Collapse file tree 3 files changed +31
-193
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 55use Proxy \Plugin \AbstractPlugin ;
66use Proxy \Event \ProxyEvent ;
77use Proxy \Config ;
8- use Proxy \Html ;
98
109class ProxifyPlugin extends AbstractPlugin {
1110
@@ -153,16 +152,6 @@ public function onCompleted(ProxyEvent $event){
153152 return ;
154153 }
155154
156- // remove JS from urls
157- $ js_remove = (array )Config::get ('js_remove ' );
158- foreach ($ js_remove as $ pattern ){
159- if (strpos ($ url_host , $ pattern ) !== false ){
160- $ str = Html::remove_scripts ($ str );
161- }
162- }
163-
164- // add html.no-js
165-
166155 // let's remove all frames?? does not protect against the frames created dynamically via javascript
167156 $ str = preg_replace ('@<iframe[^>]*>[^<]*< \\/iframe>@is ' , '' , $ str );
168157
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Proxy \Plugin ;
3+
4+ use Proxy \Plugin \AbstractPlugin ;
5+ use Proxy \Event \ProxyEvent ;
6+ use Proxy \Config ;
7+
8+ class RemoveScriptsPlugin extends AbstractPlugin
9+ {
10+ public function onCompleted (ProxyEvent $ event )
11+ {
12+ $ uri = $ event ['request ' ]->getUri ();
13+ $ response = $ event ['response ' ];
14+ $ content_type = $ response ->headers ->get ('content-type ' );
15+ if (strpos ($ content_type , 'text/html ' ) === false ) {
16+ return ;
17+ }
18+
19+ $ url_host = parse_url ($ uri , PHP_URL_HOST );
20+
21+ // remove JS from urls
22+ $ js_remove = (array )Config::get ('js_remove ' );
23+ foreach ($ js_remove as $ pattern ) {
24+ if (strpos ($ url_host , $ pattern ) !== false ) {
25+ $ content = $ response ->getContent ();
26+ $ content = preg_replace ('/<\s*script[^>]*>(.*?)<\s*\/\s*script\s*>/is ' , '' , $ content );
27+ $ response ->setContent ($ content );
28+ }
29+ }
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments