DLSite Nyaa Search

Adds live example button, with styling.

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name DLSite Nyaa Search
  3. // @description Adds live example button, with styling.
  4. // @match *://www.dlsite.com/*
  5. // @grant GM_addStyle
  6. // @license MIT
  7. // @version 0.0.1.20211208121150
  8. // @namespace https://greasyfork.org/users/850330
  9. // ==/UserScript==
  10.  
  11. //Get work name
  12. let workName = document.querySelector("h1#work_name").innerText
  13.  
  14. /*--- Create a button in a container div. It will be styled and
  15. positioned with CSS.
  16. */
  17. var zNode = document.createElement ('div');
  18. zNode.innerHTML = '<button id="myButton" type="button">'
  19. + 'Nyaa Search</button>'
  20. ;
  21. zNode.setAttribute ('id', 'myContainer');
  22. document.body.appendChild (zNode);
  23.  
  24. let div = document.querySelector("h1#work_name");
  25. div.appendChild(zNode);
  26.  
  27. //--- Activate the newly added button.
  28. document.getElementById ("myButton").addEventListener (
  29. "click", ButtonClickAction, false
  30. );
  31.  
  32. function ButtonClickAction (zEvent) {
  33. window.open('https://' + (window.location.href.split('/')[3] == 'maniax' ? 'sukebei.' : '') + 'nyaa.si/?q=' + workName);
  34. }
  35.  
  36.  
  37.