Greasy Fork is available in English.

Greasy Fork Bookmark

Bookmark the script easily

  1. // ==UserScript==
  2. // @name Greasy Fork Bookmark
  3. // @name:en Greasy Fork Bookmark
  4. // @name:ja Greasy Fork ブックマーク
  5. // @namespace http://tampermonkey.net/
  6. // @version 2024-04-24
  7. // @description Bookmark the script easily
  8. // @description:en Bookmark the script easily
  9. // @description:ja Greasy Forkのブックマーク機能
  10. // @author ぐらんぴ
  11. // @match https://greasyfork.org/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (()=>{
  18. var favs = JSON.parse(localStorage.getItem('favs')) || []
  19. function favLink(){
  20. let nav = document.querySelector("#site-nav > nav"),
  21. li = document.createElement('li')
  22. li.innerHTML = `<a href="https://greasyfork.org/Bookmarks">Favs</a>`
  23. nav.appendChild(li)
  24. }favLink()
  25. function favPage(){
  26. if(window.location.href == "https://greasyfork.org/Bookmarks"){
  27. document.title = 'bookmarks'
  28. document.querySelector("body > div > section").remove()
  29.  
  30. let scripts = JSON.parse(localStorage.getItem("favs"))
  31. document.querySelector("body > div").innerHTML = `<ol id="browse-script-list" class="script-list ">`
  32. for(let script of scripts){
  33. let elm = document.querySelector("#browse-script-list"),
  34. li = document.createElement("li")
  35. li.innerHTML = `
  36. <a class="script-link" href="${script.href}">${script.title}</a>
  37. <span class="script-description description">${script.description}`
  38. elm.appendChild(li);
  39. }
  40. }
  41. }favPage()
  42. function scriptPage(){
  43. if(location.href.match('/scripts')){
  44. let tabs = document.querySelector("#script-links"),
  45. li = document.createElement('li')
  46. li.innerHTML = `<a>☆</a>`
  47. tabs.appendChild(li)
  48. //
  49. let href = window.location.href,
  50. title = document.querySelector("#script-info > header > h2").innerText,
  51. index = -1,
  52. val = title,
  53. filteredObj = favs.find((item, i)=>{
  54. if(item.title === val){
  55. index = i;
  56. return i;
  57. }
  58. });
  59. if(index !== -1){
  60. li.innerHTML = '<a>★</a>'
  61. }
  62. li.addEventListener('click', ()=>{
  63. var value = {
  64. title: title,
  65. description: document.querySelector(".script-description").innerText,
  66. href: href,
  67. }
  68. var index = -1,
  69. val = title,
  70. filteredObj = favs.find(function(item, i){
  71. if(item.title === val){
  72. index = i;
  73. return i;
  74. }
  75. });
  76. if(index == -1){
  77. favs.push(value)
  78. li.innerHTML = '<a>★</a>'
  79. }else{
  80. favs.splice(index, 1)
  81. li.innerHTML = '<a>☆</a>'
  82. }
  83. localStorage.setItem('favs', JSON.stringify(favs))
  84. })
  85. }
  86. }scriptPage()
  87. function addStyle(){
  88. var css = `
  89. #script-links > li:nth-child(6) {
  90. text-decoration: none;
  91. cursor: pointer;
  92. color: #a42121;
  93. }`,
  94. style = document.createElement('style')
  95. style.innerHTML = css;
  96. document.head.append(style)
  97. }addStyle()
  98. })();