PageSourceSearch

https://sports.info/static/js/reader/bookmarks.js

js sports.info collected 2026-10-02 17:28:46 UTC 2,689 bytes, 78 lines download raw bytes

1var elem = document.getElementById('bookmark-js');
2let csrf_token = elem.getAttribute("csrf_token")
3let new_page_type = elem.getAttribute("page_type")
4let actual_domain_bookmarks = elem.getAttribute("actual_domain") || window.location.hostname
5
6let post_key = document.getElementById("article-post-id")?.value;
7let add_bookmark_btn =   document.querySelectorAll(`#add-bookmark-btn-`+post_key)
8let remove_bookmark_btn =   document.querySelectorAll(`#remove-bookmark-btn-`+post_key)
9
10function apiCall(post_id, URL, method, callback){
11  if (post_id === undefined || (typeof post_id !== "string" && typeof post_id !== "number") || isNaN(post_id)) return;
12  let form = new FormData()
13  form.append('post_id', post_id);
14  fetch(URL, {
15    method: method,
16    body: form,
17    headers: {
18      'X-CSRFToken': csrf_token, 
19    }
20  }).then(response => {
21    if (response.ok) {
22      return response.json();
23    } else {
24      throw new Error('Request failed with status: ' + response.status);
25    }
26  })
27  .then(data => {
28    if(callback)
29      callback(data)
30  })
31  .catch((error) => {
32    console.log(error)
33  });
34}
35
36function get_bookmark_state(){
37  function handleBookmarkButtonDisplay(data){
38    if(!data?.authorised) {
39      return;
40    } 
41    let bookmark_state = data?.bookmarked
42    if(bookmark_state) {
43      add_bookmark_btn?.forEach(item => item.style.display = "none")
44      remove_bookmark_btn?.forEach(item=> item.style.display = "block")
45    } 
46    else {
47      remove_bookmark_btn?.forEach(item=> item.style.display = "none")
48      add_bookmark_btn?.forEach(item=> item.style.display = "block")
49    }
50    document.querySelectorAll(`#bookmark-redirect-btn-`+post_key)?.forEach(item=> item.classList.add("display-none"))
51  } 
52
53  apiCall(post_key, `https://${actual_domain_bookmarks}/reader/bookmark`, "POST",  handleBookmarkButtonDisplay)
54}
55
56
57function add_bookmark(post_id){  
58  document.querySelector(`#add-bookmark-btn-${post_id}`).style.display = "none"
59  document.querySelector(`#remove-bookmark-btn-${post_id}`).style.display = "block"
60  apiCall(post_id, `https://${actual_domain_bookmarks}/reader/bookmark/bookmark-post`,"POST")
61}
62function remove_bookmark(post_id){
63  document.querySelector(`#add-bookmark-btn-${post_id}`).style.display = "block"
64  document.querySelector(`#remove-bookmark-btn-${post_id}`).style.display = "none"
65  apiCall(post_id, `https://${actual_domain_bookmarks}/reader/bookmark/remove-bookmark`,"POST")
66}
67
68if(new_page_type!='BookMarksPage') {
69  if (!window?.eventBus) {
70    $(document).ready(function(){
71      get_bookmark_state()
72    })
73  } else {
74    window?.eventBus?.subscribe?.("user:authenticated", (data) => {
75      get_bookmark_state()
76    })
77  }
78}

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.