|
24 | 24 |
|
25 | 25 | // cSpell:ignore Dumpert, dumpert, geenstijl, powned, daskapital, glamora, perma |
26 | 26 |
|
27 | | -(function() { |
28 | | - |
| 27 | +(function () { |
29 | 28 | function proxy(fn) { |
30 | | - return function() { |
| 29 | + return function () { |
31 | 30 | var that = this; |
32 | | - return function(e) { |
33 | | - var args = that.slice(0); // clone; |
34 | | - args.unshift(e); // prepend event; |
| 31 | + return function (e) { |
| 32 | + var args = that.slice(0); // clone; |
| 33 | + args.unshift(e); // prepend event; |
35 | 34 | fn.apply(this, args); |
36 | 35 | }; |
37 | 36 | }.call([].slice.call(arguments, 1)); |
38 | 37 | } |
39 | 38 |
|
40 | 39 | function wait(condition, next) { |
41 | | - var loop = window.setInterval(function() { |
| 40 | + var loop = window.setInterval(function () { |
42 | 41 | if (condition() === true) { |
43 | 42 | window.clearInterval(loop); |
44 | 43 | next(); |
45 | 44 | } |
46 | 45 | }, 100); |
47 | 46 | } |
48 | 47 |
|
49 | | - String.format = function(string) { |
| 48 | + String.format = function (string) { |
50 | 49 | var args = Array.prototype.slice.call(arguments, 1, arguments.length); |
51 | | - return string.replace(/{(\d+)}/g, function(match, number) { |
| 50 | + return string.replace(/{(\d+)}/g, function (match, number) { |
52 | 51 | return typeof args[number] !== "undefined" ? args[number] : match; |
53 | 52 | }); |
54 | 53 | }; |
55 | 54 |
|
56 | | - var replyImgScr = "data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABcSURBVChTjZBbDsAgCATl2PDFzW236RjqI+kmSsBxQS0i+q2GzKzVfBy8oOCj3L03bRIROjNHbQGBgRQx+TgC6ALQEawtGeNpzWNwETjD2xlVrGtp/et7ZpddfgEnfhsfVr//KQAAAABJRU5ErkJgggA="; |
57 | | - var permaImgScr = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABZ0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMDvo9WkAAABfSURBVChTXY9BEsAgCAP7bMqpL4euDaJ2D0xMzKDXvWFmpSYjzsyIYP4YMQ2y7+rRrlhKh2ci091XDH1DJnPtlgsIetpYsTImmoxHVLuVMsHxaDf7D+tpQr/CAjnu/gJVo8cY6M1GEAAAAABJRU5ErkJggg=="; |
| 55 | + var replyImgScr = |
| 56 | + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABcSURBVChTjZBbDsAgCATl2PDFzW236RjqI+kmSsBxQS0i+q2GzKzVfBy8oOCj3L03bRIROjNHbQGBgRQx+TgC6ALQEawtGeNpzWNwETjD2xlVrGtp/et7ZpddfgEnfhsfVr//KQAAAABJRU5ErkJgggA="; |
| 57 | + var permaImgScr = |
| 58 | + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABZ0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMDvo9WkAAABfSURBVChTXY9BEsAgCAP7bMqpL4euDaJ2D0xMzKDXvWFmpSYjzsyIYP4YMQ2y7+rRrlhKh2ci091XDH1DJnPtlgsIetpYsTImmoxHVLuVMsHxaDf7D+tpQr/CAjnu/gJVo8cY6M1GEAAAAABJRU5ErkJggg=="; |
58 | 59 |
|
59 | 60 | var commentsList = document.getElementById("comments"); |
60 | 61 | if (commentsList) { |
61 | | - wait(function() { |
62 | | - return commentsList.querySelectorAll("article .nsb,.comment .nsb").length > 0; |
63 | | - }, function() { |
64 | | - Array.forEach(commentsList.querySelectorAll("article,.comment"), function(comment) { |
65 | | - var footer = comment.querySelector("footer,.footer"); |
| 62 | + wait( |
| 63 | + function () { |
| 64 | + return ( |
| 65 | + commentsList.querySelectorAll("article .nsb,.comment .nsb") |
| 66 | + .length > 0 |
| 67 | + ); |
| 68 | + }, |
| 69 | + function () { |
| 70 | + Array.forEach( |
| 71 | + commentsList.querySelectorAll("article,.comment"), |
| 72 | + function (comment) { |
| 73 | + var footer = comment.querySelector("footer,.footer"); |
66 | 74 |
|
67 | | - if (comment.id) { |
68 | | - var perma = document.createElement("a"); |
69 | | - perma.classList.add("nsb"); |
70 | | - perma.setAttribute("href", String.format("#{0}", comment.id)); |
71 | | - perma.setAttribute("title", String.format("Permalink #{0}", comment.id)); |
72 | | - perma.style.backgroundImage = String.format("url('{0}')", permaImgScr); |
73 | | - perma.style.backgroundPosition = "center center"; |
74 | | - perma.style.marginRight = "4px"; |
75 | | - if (/https?:\/\/www\.powned\.tv\/nieuws\/.*/.test(location.href)) { // add missing css; |
76 | | - perma.style.cursor = "pointer"; |
77 | | - perma.style.cssFloat = "right"; |
78 | | - perma.style.height = perma.style.width = "10px"; |
79 | | - } |
80 | | - footer.appendChild(perma); |
81 | | - } |
| 75 | + if (comment.id) { |
| 76 | + var perma = document.createElement("a"); |
| 77 | + perma.classList.add("nsb"); |
| 78 | + perma.setAttribute( |
| 79 | + "href", |
| 80 | + String.format("#{0}", comment.id), |
| 81 | + ); |
| 82 | + perma.setAttribute( |
| 83 | + "title", |
| 84 | + String.format("Permalink #{0}", comment.id), |
| 85 | + ); |
| 86 | + perma.style.backgroundImage = String.format( |
| 87 | + "url('{0}')", |
| 88 | + permaImgScr, |
| 89 | + ); |
| 90 | + perma.style.backgroundPosition = "center center"; |
| 91 | + perma.style.marginRight = "4px"; |
| 92 | + if ( |
| 93 | + /https?:\/\/www\.powned\.tv\/nieuws\/.*/.test( |
| 94 | + location.href, |
| 95 | + ) |
| 96 | + ) { |
| 97 | + // add missing css; |
| 98 | + perma.style.cursor = "pointer"; |
| 99 | + perma.style.cssFloat = "right"; |
| 100 | + perma.style.height = perma.style.width = "10px"; |
| 101 | + } |
| 102 | + footer.appendChild(perma); |
| 103 | + } |
82 | 104 |
|
83 | | - var textArea = document.getElementById("text"); |
84 | | - if (textArea) { |
85 | | - var reply = document.createElement("span"); |
86 | | - reply.classList.add("nsb"); |
87 | | - reply.setAttribute("title", "Beantwoorden"); |
88 | | - reply.style.backgroundImage = String.format("url('{0}')", replyImgScr); |
89 | | - reply.style.backgroundPosition = "center center"; |
90 | | - reply.style.marginRight = "4px"; |
91 | | - if (/https?:\/\/www\.powned\.tv\/nieuws\/.*/.test(location.href)) { // add missing css; |
92 | | - reply.style.cursor = "pointer"; |
93 | | - reply.style.cssFloat = "right"; |
94 | | - reply.style.height = reply.style.width = "10px"; |
95 | | - } |
96 | | - reply.addEventListener("click", proxy(function() { |
97 | | - textArea.value += String.format("@{0}\n", Array.map(this.childNodes, function(node) { |
98 | | - return (node.nodeType === 3) ? node.textContent.trim() : ""; |
99 | | - }).join(" ").trim().replace(/\s{2,}/, " ").replace(/\s?\|\s?$/g, "")); |
100 | | - textArea.focus(); |
101 | | - textArea.scrollIntoView(); |
102 | | - }).bind(footer)); |
103 | | - footer.appendChild(reply); |
104 | | - } |
105 | | - }); |
106 | | - }); |
| 105 | + var textArea = document.getElementById("text"); |
| 106 | + if (textArea) { |
| 107 | + var reply = document.createElement("span"); |
| 108 | + reply.classList.add("nsb"); |
| 109 | + reply.setAttribute("title", "Beantwoorden"); |
| 110 | + reply.style.backgroundImage = String.format( |
| 111 | + "url('{0}')", |
| 112 | + replyImgScr, |
| 113 | + ); |
| 114 | + reply.style.backgroundPosition = "center center"; |
| 115 | + reply.style.marginRight = "4px"; |
| 116 | + if ( |
| 117 | + /https?:\/\/www\.powned\.tv\/nieuws\/.*/.test( |
| 118 | + location.href, |
| 119 | + ) |
| 120 | + ) { |
| 121 | + // add missing css; |
| 122 | + reply.style.cursor = "pointer"; |
| 123 | + reply.style.cssFloat = "right"; |
| 124 | + reply.style.height = reply.style.width = "10px"; |
| 125 | + } |
| 126 | + reply.addEventListener( |
| 127 | + "click", |
| 128 | + proxy(function () { |
| 129 | + textArea.value += String.format( |
| 130 | + "@{0}\n", |
| 131 | + Array.map( |
| 132 | + this.childNodes, |
| 133 | + function (node) { |
| 134 | + return node.nodeType === 3 |
| 135 | + ? node.textContent.trim() |
| 136 | + : ""; |
| 137 | + }, |
| 138 | + ) |
| 139 | + .join(" ") |
| 140 | + .trim() |
| 141 | + .replace(/\s{2,}/, " ") |
| 142 | + .replace(/\s?\|\s?$/g, ""), |
| 143 | + ); |
| 144 | + textArea.focus(); |
| 145 | + textArea.scrollIntoView(); |
| 146 | + }).bind(footer), |
| 147 | + ); |
| 148 | + footer.appendChild(reply); |
| 149 | + } |
| 150 | + }, |
| 151 | + ); |
| 152 | + }, |
| 153 | + ); |
107 | 154 | } |
108 | | - |
109 | 155 | })(); |
0 commit comments