PageSourceSearch

https://mrx.la/fp-plugins/plainpresstoolkit/res/protected-download.js?v=1.30.4

js mrx.la collected 2026-10-08 01:57:47 UTC 2,285 bytes, 47 lines download raw bytes

1(function () {
2  'use strict';
3  var script = document.currentScript;
4  var ticketEndpoint = script && script.dataset.ticketEndpoint ? script.dataset.ticketEndpoint : '/index.php?ppt_download_ticket=1';
5
6  function setCardState(card, state, message) {
7    if (!card) return;
8    card.dataset.pptDownloadState = state || '';
9	if (card.matches && card.matches('.ppt-protected-download')) {
10	  if (!card.dataset.pptOriginalLabel) card.dataset.pptOriginalLabel = card.textContent;
11	  card.textContent = message || card.dataset.pptOriginalLabel;
12	  if (state === 'loading') card.setAttribute('aria-busy', 'true'); else card.removeAttribute('aria-busy');
13	  return;
14	}
15    Array.prototype.forEach.call(card.querySelectorAll('[data-ppt-download-label]'), function (label) {
16      label.textContent = message || '下载';
17    });
18    Array.prototype.forEach.call(card.querySelectorAll('.ppt-protected-download'), function (link) {
19      if (state === 'loading') link.setAttribute('aria-busy', 'true'); else link.removeAttribute('aria-busy');
20    });
21  }
22
23  document.addEventListener('click', function (event) {
24    var link = event.target && event.target.closest ? event.target.closest('.ppt-protected-download') : null;
25    if (!link) return;
26    event.preventDefault();
27	var card = link.closest('.ppt-download-card') || link;
28	if (card.dataset.pptDownloadState === 'loading' || !link.dataset.pptDownload) return;
29    setCardState(card, 'loading', '正在准备…');
30    fetch(ticketEndpoint, {
31      method: 'POST', credentials: 'same-origin', cache: 'no-store',
32      headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Accept': 'application/json' },
33      body: 'file=' + encodeURIComponent(link.dataset.pptDownload)
34    }).then(function (response) {
35      return response.json().then(function (payload) {
36        if (!response.ok || !payload.ok || !payload.url) throw new Error(payload.error || '无法生成下载链接');
37        return payload;
38      });
39    }).then(function (payload) {
40      setCardState(card, '', '下载');
41      window.location.assign(payload.url);
42    }).catch(function (error) {
43      setCardState(card, 'error', '重试');
44      if (card) card.setAttribute('title', error.message || '下载失败,请重试');
45    });
46  });
47}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.