Greasy Fork is available in English.

CT_pers_note

Комментарий на странице информации о персе

  1. // ==UserScript==
  2. // @name CT_pers_note
  3. // @namespace CheckT
  4. // @author CheckT
  5. // @description Комментарий на странице информации о персе
  6. // @version 1.1
  7. // @encoding utf-8
  8. // @homepage https://greasyfork.org/en/scripts/376330-ct-pers-note
  9. // @include https://www.heroeswm.ru/pl_info.php*
  10. // @include https://www.lordswm.com/pl_info.php*
  11. // @include http://178.248.235.15/pl_info.php*
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // ==/UserScript==
  15.  
  16. (function(){
  17. var gm_prefix = 'ctpn_';
  18. initGm();
  19. try{
  20. var pl_id = document.location.href.split('?id=')[1].split('&')[0];
  21. }catch(e){console.log('CT_pers_note error: '+e);return;}
  22. if(pl_id){
  23. var img_clan_war = document.querySelector('img[src*="unk_kukla.png"]');
  24. if(img_clan_war){
  25. create_input(img_clan_war);
  26. } else {
  27. var table_kukla = document.querySelector('table[background*="i/kukla"]');
  28. if(table_kukla){
  29. create_input(table_kukla);
  30. }
  31. }
  32. addEvent($$GM('notes'), "change", change_info);
  33. }
  34.  
  35. return;
  36.  
  37. function create_input(elt){
  38. var root_table = elt.parentNode.parentNode.parentNode.parentNode;
  39. var tr = root_table.insertRow(1);
  40. tr.innerHTML = '<td colspan="3"><input type="text" value="'+gm_get(pl_id)+'" id="'+gm_prefix+'notes" style="width:315px"/> (любой комментарий, виден только Вам)</td>';
  41. }
  42.  
  43. function change_info(){
  44. gm_set(pl_id, $$GM('notes').value);
  45. }
  46.  
  47. function $$GM(id) { return document.getElementById(gm_prefix+id); }
  48.  
  49. function addChangeEvent_GM(id, func){
  50. addEvent($$GM(id), "change", func);
  51. }
  52.  
  53. function addEvent(elem, evType, fn) {
  54. if(elem && fn){
  55. if (elem.addEventListener)
  56. elem.addEventListener(evType, fn, false);
  57. else if (elem.attachEvent)
  58. elem.attachEvent("on" + evType, fn);
  59. else
  60. elem["on" + evType] = fn;
  61. }
  62. }
  63.  
  64. function gm_get(key){
  65. return GM_getValue(gm_prefix+key, '');
  66. }
  67.  
  68. function gm_set(key, val){
  69. return GM_setValue(gm_prefix+key, val);
  70. }
  71.  
  72. function initGm(){
  73. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  74. this.GM_getValue=function (key,def) {
  75. return localStorage[key] || def;
  76. };
  77. this.GM_setValue=function (key,value) {
  78. return localStorage[key]=value;
  79. };
  80. this.GM_deleteValue=function (key) {
  81. return delete localStorage[key];
  82. };
  83. }
  84. if (!this.GM_listValues || (this.GM_listValues.toString && this.GM_listValues.toString().indexOf("not supported")>-1)) {
  85. this.GM_listValues=function () {
  86. var keys=[];
  87. for (var key in localStorage){
  88. //в K-Meleon возвращаются все опции всех скриптов
  89. keys.push(key);
  90. }
  91. return keys;
  92. }
  93. }
  94. }
  95. })();