How to i make working SPF? #698
|
Not entirely related to rehike, but I think people here might know how to answer me. |
Replies: 1 comment 1 reply
|
SPF requests are performed by YouTube's JavaScript client on HTML5-compatible browsers (so IE9+) on click events to all anchor elements with a same-domain origin featuring an We only account for the following cases: Rehike/modules/Rehike/Spf/Spf.php Lines 27 to 30 in a847e38 The SPF response contains the same exact HTML as a regular response in almost all cases (on real YouTube, feed pages leaked the InternalTube debugger for YEARS), but only including the requested fragments. Usually, it's just the page content which updates, so it doesn't really save on anything, but it does look nicer. SPF is also used for loading the initial comments view on the watch page since a rewrite in 2016. Basically, you need to return JSON (with the Here's a tip for integrating things into existing code which likely doesn't account for SPF's different markup: use output buffering to capture the desired bits of HTML and store it in a string instead of outputting to the browser: <div id="content">
<?php ob_start() ?>
<some-content></some-content>
<?php $contentBody = ob_get_clean() ?>
</div>or with Twig, you can use <div id="content">
{% set content_body %}
<some-content></some-content>
{% endset %}
</div>SPF is actually open source and you can learn a lot from their GitHub and homepage: Here's the single template we use for the majority of SPF requests; all standard pages: https://github.com/Rehike/Rehike/blob/master/template/hitchhiker/core/core_spf.twig Here's the template which we use for the special condition of loading comments ( Here's the template which we use for the special condition of loading the delay-loaded guide (also |
SPF requests are performed by YouTube's JavaScript client on HTML5-compatible browsers (so IE9+) on click events to all anchor elements with a same-domain origin featuring an
spf-linkclass, as well as in some other special cases. In such cases, the request has a parameterspf=navigateinserted into the URL parameters.We only account for the following cases:
Rehike/modules/Rehike/Spf/Spf.php
Lines 27 to 30 in a847e38
The SPF response contains the same exact HTML as a regular response in almost all cases (on real YouTube, feed pages leaked the InternalTube debugger for YEARS), but…