require for ReSpeed

require for ReSpeed !

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/16910/106155/require%20for%20ReSpeed.js

  1. if (!window.InstantClick) {
  2. /* InstantClick 3.1.0 | (C) 2014 Alexandre Dieulot | http://instantclick.io/license */
  3. // With added respeedcancel event
  4. var InstantClick=function(d,e){function w(a){var b=a.indexOf("#");return 0>b?a:a.substr(0,b)}function z(a){for(;a&&"A"!=a.nodeName;)a=a.parentNode;return a}function A(a){var b=e.protocol+"//"+e.host;if(!(b=a.target||a.hasAttribute("download")||0!=a.href.indexOf(b+"/")||-1<a.href.indexOf("#")&&w(a.href)==k)){if(J){a:{do{if(!a.hasAttribute)break;if(a.hasAttribute("data-no-instant"))break;if(a.hasAttribute("data-instant")){a=!0;break a}}while(a=a.parentNode);a=!1}a=!a}else a:{do{if(!a.hasAttribute)break;
  5. if(a.hasAttribute("data-instant"))break;if(a.hasAttribute("data-no-instant")){a=!0;break a}}while(a=a.parentNode);a=!1}b=a}return b?!1:!0}function t(a,b,c,g){for(var d=!1,e=0;e<B[a].length;e++)if("receive"==a){var f=B[a][e](b,c,g);f&&("body"in f&&(c=f.body),"title"in f&&(g=f.title),d=f)}else B[a][e](b,c,g);return d}function K(a,b,c,g){d.documentElement.replaceChild(b,d.body);if(c){history.pushState(null,null,c);b=c.indexOf("#");b=-1<b&&d.getElementById(c.substr(b+1));g=0;if(b)for(;b.offsetParent;)g+=
  6. b.offsetTop,b=b.offsetParent;scrollTo(0,g);k=w(c)}else scrollTo(0,g);d.title=S&&d.title==a?a+String.fromCharCode(160):a;L();C.done();t("change",!1);a=d.createEvent("HTMLEvents");a.initEvent("instantclick:newpage",!0,!0);dispatchEvent(a)}function M(a){G>+new Date-500||(a=z(a.target))&&A(a)&&x(a.href)}function N(a){G>+new Date-500||(a=z(a.target))&&A(a)&&(a.addEventListener("mouseout",T),H?(O=a.href,l=setTimeout(x,H)):x(a.href))}function U(a){G=+new Date;(a=z(a.target))&&A(a)&&(D?a.removeEventListener("mousedown",
  7. M):a.removeEventListener("mouseover",N),x(a.href))}function V(a){var b=z(a.target);!b||!A(b)||1<a.which||a.metaKey||a.ctrlKey||(a.preventDefault(),P(b.href))}function T(){l?(clearTimeout(l),l=!1):v&&!m&&(p.abort(),t("respeedcancel"),m=v=!1)}function W(){if(!(4>p.readyState)&&0!=p.status){q.ready=+new Date-q.start;if(p.getResponseHeader("Content-Type").match(/\/(x|ht|xht)ml/)){var a=d.implementation.createHTMLDocument("");a.documentElement.innerHTML=p.responseText.replace(/<noscript[\s\S]*?<\/noscript>/gi,"");y=a.title;
  8. u=a.body;var b=t("receive",r,u,y);b&&("body"in b&&(u=b.body),"title"in b&&(y=b.title));b=w(r);h[b]={body:u,title:y,scrollY:b in h?h[b].scrollY:0};for(var a=a.head.children,b=0,c,g=a.length-1;0<=g;g--)if(c=a[g],c.hasAttribute("data-instant-track")){c=c.getAttribute("href")||c.getAttribute("src")||c.innerHTML;for(var e=E.length-1;0<=e;e--)E[e]==c&&b++}b!=E.length&&(F=!0)}else F=!0;m&&(m=!1,P(r))}}function L(a){d.body.addEventListener("touchstart",U,!0);D?d.body.addEventListener("mousedown",M,!0):d.body.addEventListener("mouseover",
  9. N,!0);d.body.addEventListener("click",V,!0);if(!a){a=d.body.getElementsByTagName("script");var b,c,g,e;i=0;for(j=a.length;i<j;i++)b=a[i],b.hasAttribute("data-no-instant")||(c=d.createElement("script"),b.src&&(c.src=b.src),b.innerHTML&&(c.innerHTML=b.innerHTML),g=b.parentNode,e=b.nextSibling,g.removeChild(b),g.insertBefore(c,e))}}function x(a){!D&&"display"in q&&100>+new Date-(q.start+q.display)||(l&&(clearTimeout(l),l=!1),a||(a=O),v&&(a==r||m))||(v=!0,m=!1,r=a,F=u=!1,q={start:+new Date},t("fetch"),
  10. p.open("GET",a),p.send())}function P(a){"display"in q||(q.display=+new Date-q.start);l||!v?l&&r&&r!=a?e.href=a:(x(a),C.start(0,!0),t("wait"),m=!0):m?e.href=a:F?e.href=r:u?(h[k].scrollY=pageYOffset,m=v=!1,K(y,u,r)):(C.start(0,!0),t("wait"),m=!0)}var I=navigator.userAgent,S=-1<I.indexOf(" CriOS/"),Q="createTouch"in d,k,O,l,G,h={},p,r=!1,y=!1,F=!1,u=!1,q={},v=!1,m=!1,E=[],J,D,H,B={fetch:[],receive:[],wait:[],change:[],respeedcancel:[]},C=function(){function a(a,e){n=a;d.getElementById(f.id)&&d.body.removeChild(f);f.style.opacity=
  11. "1";d.getElementById(f.id)&&d.body.removeChild(f);g();e&&setTimeout(b,0);clearTimeout(l);l=setTimeout(c,500)}function b(){n=10;g()}function c(){n+=1+2*Math.random();98<=n?n=98:l=setTimeout(c,500);g()}function g(){h.style[k]="translate("+n+"%)";d.getElementById(f.id)||d.body.appendChild(f)}function e(){d.getElementById(f.id)?(clearTimeout(l),n=100,g(),f.style.opacity="0"):(a(100==n?0:n),setTimeout(e,0))}function m(){f.style.left=pageXOffset+"px";f.style.width=innerWidth+"px";f.style.top=pageYOffset+
  12. "px";var a="orientation"in window&&90==Math.abs(orientation);f.style[k]="scaleY("+innerWidth/screen[a?"height":"width"]*2+")"}var f,h,k,n,l;return{init:function(){f=d.createElement("div");f.id="instantclick";h=d.createElement("div");h.id="instantclick-bar";h.className="instantclick-bar";f.appendChild(h);var a=["Webkit","Moz","O"];k="transform";if(!(k in h.style))for(var b=0;3>b;b++)a[b]+"Transform"in h.style&&(k=a[b]+"Transform");var c="transition";if(!(c in h.style))for(b=0;3>b;b++)a[b]+"Transition"in
  13. h.style&&(c="-"+a[b].toLowerCase()+"-"+c);a=d.createElement("style");a.innerHTML="#instantclick{position:"+(Q?"absolute":"fixed")+";top:0;left:0;width:100%;pointer-events:none;z-index:2147483647;"+c+":opacity .25s .1s}.instantclick-bar{background:#29d;width:100%;margin-left:-100%;height:2px;"+c+":all .25s}";d.head.appendChild(a);Q&&(m(),addEventListener("resize",m),addEventListener("scroll",m))},start:a,done:e}}(),R="pushState"in history&&(!I.match("Android")||I.match("Chrome/"))&&"file:"!=e.protocol;
  14. return{supported:R,init:function(){if(!k)if(R){for(var a=arguments.length-1;0<=a;a--){var b=arguments[a];!0===b?J=!0:"mousedown"==b?D=!0:"number"==typeof b&&(H=b)}k=w(e.href);h[k]={body:d.body,title:d.title,scrollY:pageYOffset};for(var b=d.head.children,c,a=b.length-1;0<=a;a--)c=b[a],c.hasAttribute("data-instant-track")&&(c=c.getAttribute("href")||c.getAttribute("src")||c.innerHTML,E.push(c));p=new XMLHttpRequest;p.addEventListener("readystatechange",W);L(!0);C.init();t("change",!0);addEventListener("popstate",
  15. function(){var a=w(e.href);a!=k&&(a in h?(h[k].scrollY=pageYOffset,k=a,K(h[a].title,h[a].body,!1,h[a].scrollY)):e.href=e.href)})}else t("change",!0)},on:function(a,b){B[a].push(b)}}}(document,location);
  16. }
  17.  
  18. if (location.host == 'www.jeuxvideo.com'
  19. && !!document.querySelector('html').lang // Don’t load when we display a script/stylesheet, at least Chrome Tampermonkey does load userscripts there
  20. && location.pathname.substr(1, 12) != 'screenshots/') { // Many layout bugs on the Visionneuse, and it’s useless there
  21.  
  22.  
  23.  
  24. /***** VARIABLES *****/
  25.  
  26. var checkFooterFilledInterval
  27. , footerHtml = '<div class="liens-pied"><div class="container container-empty"><ul><li><span class="JvCare 1F424F49CB4A42CB19C045C0 a-footer">Contact</span></li><li><span class="JvCare 1F4E4A4648444FC14E19C045C0 a-footer">L\'équipe</span></li><li><span class="JvCare 1F424FC0C6C1464C45CB1945CB4E a-footer">Informations légales</span></li><li><span class="JvCare 1F424CC31945CB4E a-footer">C.G.U.</span></li><li><span class="JvCare 1F4943CCC24843CBCB43C11F a-footer">Newsletter</span></li><li><span class="JvCare 1FC04AC1CB43494A46C143C21945CB4E a-footer">Partenaires</span></li><li><span class="JvCare 1F4DC4C54E481945CB4E a-footer">RSS</span></li><li><span class="JvCare 1FC14342C1C3CB431945CB4E a-footer">Jobs</span></li></ul> <p>jeuxvideo.com, c\'est édité par L\'Odyssée Interactive, société du groupe <span class="JvCare 45CBCBC02D1F1FCCCCCC19CC4341434B464A1944C11F a-footer" rel="external" target="_blank">Webedia</span>. Fréquentation certifiée par l\'<span class="JvCare 45CBCBC02D1F1FCCCCCC194F4D4B1E4649CB43C14943CB19424F4E1F4245464444C143C21E4649CB43C14943CB1F2C232A201E4D43C3C5C4464B434F19424F4E a-footer" rel="external" target="_blank">OJD</span><br>Copyright © 1997-2014 <span rel="external" class="JvCare 45CBCBC02D1F1FCCCCCC194F4BC6C2C243431E4649CB43C14A42CB46C44319424F4E1F a-footer" target="_blank">L\'Odyssée Interactive</span> Tous droits réservés.</p><script src="/static/1.18.3/js/hp.js" type="text/javascript"></script><script src="/static/1.18.3/js/forum.js" type="text/javascript"></script></div></div>'
  28. , scriptsBlackList = [
  29. ''
  30. ]
  31. , styleSheets = [
  32. '/static/1.18.3/css/skin-common.css',
  33. '/static/1.18.3/css/skin-forum.css',
  34. '/static/1.18.3/css/skin-common.css',
  35. '/static/1.18.3/css/skin-hp.css'
  36. ]
  37. , locationHost = location.protocol + '//' + location.host
  38. , previousPage = location.pathname + location.search
  39. , previousScroll = 0
  40. , slowSiteWarningTimer
  41. , statsLastHover = false
  42. , statsClicksMinusHovers = []
  43. , statsLastMousedown = false
  44. , statsClicksMinusMousedowns = []
  45. , statsCancels = []
  46. , statsMousewheelsMinusHovers = []
  47. , version = localStorage.RespeedVersion
  48.  
  49.  
  50.  
  51. /***** FUNCTIONS *****/
  52.  
  53. function debug(msg) {
  54. if (!('RespeedDebug' in localStorage) && localStorage.RespeedDebug != '0') {
  55. return
  56. }
  57. console.log(typeof msg == 'string' ? ('Respeed: ' + msg) : msg)
  58. }
  59.  
  60. function cleanJvCare(node) {
  61. var spans = node.querySelectorAll('.JvCare')
  62. , attributes = 'target rel title id'.split(' ')
  63. , base16 = '0A12B34C56D78E9F'
  64. , anchor
  65. , span
  66. , attribute
  67. , attributeValue
  68. , spanParent
  69. , j
  70. , spanClasses
  71. , hiddenHref
  72. , realHref
  73.  
  74. for (var i = 0; i < spans.length; i++) {
  75. span = spans[i]
  76. anchor = document.createElement('a')
  77.  
  78. anchor.setAttribute('respeed-jvcare', '')
  79. for (j = 0; j < attributes.length; j++) {
  80. attribute = attributes[j]
  81. if (attributeValue = span.getAttribute(attribute)) {
  82. anchor.setAttribute(attribute, attributeValue)
  83. }
  84. }
  85. anchor.innerHTML = span.innerHTML
  86.  
  87. anchor.classList.add('xXx')
  88. spanClasses = span.classList
  89. hiddenHref = spanClasses[1]
  90. realHref = ''
  91. for (j = 0; j < hiddenHref.length; j += 2) {
  92. realHref += String.fromCharCode(base16.indexOf(hiddenHref[j]) * 16 + base16.indexOf(hiddenHref[j + 1]))
  93. }
  94. anchor.href = realHref
  95.  
  96. for (j = 2; j < spanClasses.length; j++) {
  97. anchor.classList.add(spanClasses[j])
  98. }
  99.  
  100. spanParent = span.parentNode
  101. spanParent.insertBefore(anchor, span)
  102. spanParent.removeChild(span)
  103. }
  104. return node
  105. }
  106.  
  107. function showSlowSiteWarning() {
  108. var element = document.createElement('div')
  109. element.id = 'slowSiteWarningContainer'
  110. element.innerHTML = '<div id="slowSiteWarning">Le site met du temps à charger…</div>'
  111. document.body.appendChild(element)
  112. }
  113.  
  114. function removeSlowSiteWarning() {
  115. var element = document.getElementById('slowSiteWarningContainer')
  116. if (element) {
  117. document.body.removeChild(element)
  118. }
  119. }
  120.  
  121. function processDelayStats() {
  122. localStorage.RespeedStatsClicksMinusHovers3 = statsClicksMinusHovers.join(' ')
  123. localStorage.RespeedStatsClicksMinusMousedowns3 = statsClicksMinusMousedowns.join(' ')
  124. localStorage.RespeedStatsCancels3 = statsCancels.join(' ')
  125. localStorage.RespeedStatsMousewheelsMinusHovers3 = statsMousewheelsMinusHovers.join(' ')
  126.  
  127. if (statsClicksMinusHovers.length >= 50) {
  128. var xhrStats = new XMLHttpRequest()
  129. , params = ''
  130.  
  131. params += 'clicks_minus_hovers=' + localStorage.RespeedStatsClicksMinusHovers3
  132. params += '&clicks_minus_mousedowns=' + localStorage.RespeedStatsClicksMinusMousedowns3
  133. params += '&cancels=' + localStorage.RespeedStatsCancels3
  134. params += '&mousewheels_minus_hovers=' + localStorage.RespeedStatsMousewheelsMinusHovers3
  135. params += '&version=' + version
  136.  
  137. xhrStats.open('POST', 'http://respeed.' + ('RespeedSendStatsToDev' in localStorage ? 'dev' : 'fr') + '/collect_delays')
  138. xhrStats.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
  139. xhrStats.send(params)
  140.  
  141. statsClicksMinusHovers = []
  142. localStorage.removeItem('RespeedStatsClicksMinusHovers2')
  143. statsClicksMinusMousedowns = []
  144. localStorage.removeItem('RespeedStatsClicksMinusMousedowns')
  145. statsCancels = []
  146. localStorage.removeItem('RespeedStatsCancels2')
  147. statsMousewheelsMinusHovers = []
  148. localStorage.removeItem('RespeedStatsMousewheelsMinusHovers3')
  149. }
  150. }
  151.  
  152. function getLinkTarget(target) {
  153. while (target && target.nodeName != 'A') {
  154. target = target.parentNode
  155. }
  156. return target
  157. }
  158.  
  159. function removeLocalStorageItems() {
  160. for (var i = 0; i < arguments.length; i++) {
  161. if (arguments[i] in localStorage) {
  162. localStorage.removeItem(arguments[i])
  163. }
  164. }
  165. }
  166.  
  167.  
  168.  
  169. /***** ON FETCH *****/
  170.  
  171. InstantClick.on('fetch', function() {
  172. /* Delay stats */
  173. statsLastHover = +new Date
  174.  
  175. // Update vars from localStorage, because if the user uses multiple tabs each Respeed
  176. // instance will overwrite on top of each other
  177. if ('RespeedStatsClicksMinusHovers2' in localStorage && localStorage.RespeedStatsClicksMinusHovers2 != statsClicksMinusHovers.join(' ')) {
  178. statsClicksMinusHovers = localStorage.RespeedStatsClicksMinusHovers2.split(' ')
  179. statsClicksMinusMousedowns = localStorage.RespeedStatsClicksMinusMousedowns.split(' ')
  180. }
  181. if ('RespeedStatsCancels2' in localStorage && localStorage.RespeedStatsCancels2 != statsCancels.join(' ')) {
  182. statsCancels = localStorage.RespeedStatsCancels2.split(' ')
  183. }
  184. })
  185.  
  186.  
  187.  
  188. /***** ON RECEIVE *****/
  189.  
  190. InstantClick.on('receive', function(url, body, title) {
  191. ;[].forEach.call(body.getElementsByTagName('script'), function (script) {
  192. var src = script.getAttribute('src')
  193. var index = scriptsBlackList.indexOf(src)
  194. if ((index > -1 || !src || !RegExp("^/(js|jwplayer)/").test(src)) && script.innerHTML.indexOf('var id_forum') == -1) {
  195. script.setAttribute('data-no-instant', '')
  196. }
  197. })
  198.  
  199. /* var jv_feedback = body.querySelector('#jv-feedback')
  200. if (jv_feedback) {
  201. body.removeChild(jv_feedback)
  202. }*/
  203.  
  204. var prospect = body.querySelector('#prospect')
  205. if (prospect) {
  206. prospect.setAttribute('hidden', '')
  207. }
  208.  
  209. var jv_footer = body.querySelector('#jv-footer')
  210. if (jv_footer) {
  211. jv_footer.innerHTML = footerHtml
  212. }
  213. clearInterval(checkFooterFilledInterval)
  214.  
  215. var image_dstats = body.querySelector('#image_dstats')
  216. if (image_dstats) {
  217. image_dstats.parentNode.removeChild(image_dstats)
  218. }
  219.  
  220. body = cleanJvCare(body)
  221.  
  222. previousScroll = scrollY
  223.  
  224. return {
  225. body: body
  226. }
  227. })
  228.  
  229.  
  230.  
  231. /***** ON CHANGE *****/
  232.  
  233. InstantClick.on('change', function(isInitialLoad) {
  234. /* Stats on mousedown */
  235. document.body.addEventListener('mousedown', function(e) {
  236. if (e.which > 1) {
  237. return
  238. }
  239. statsLastMousedown = +new Date
  240. })
  241.  
  242. /* Stats on mousewheel clicks, Firefox */
  243. document.body.addEventListener('mouseup', function(e) {
  244. if (e.button != 1 || !getLinkTarget(e.target)) {
  245. return
  246. }
  247. if (statsLastHover) { // Not there if wheelclicking on a _blank link
  248. statsMousewheelsMinusHovers.push((+new Date) - statsLastHover)
  249. statsLastHover = false
  250. }
  251. processDelayStats()
  252. })
  253.  
  254. ;[].forEach.call(document.querySelectorAll('.list-msg tr:not(.lu) .sujet-msg a'), function (non_lu) {
  255. non_lu.setAttribute('data-no-instant', '')
  256. })
  257.  
  258. var messages_precedents = document.querySelector('.btn-25-msg')
  259. if (messages_precedents) {
  260. messages_precedents.setAttribute('data-no-instant', '')
  261. }
  262.  
  263. ;[].forEach.call(document.querySelectorAll('.bloc-pre-right'), function (refreshContainer) {
  264. refreshContainer.innerHTML = '<a href="' + location.pathname + location.search + '"><span class="btn btn-actu-new-list-forum">Actualiser</span></a>'
  265. })
  266.  
  267. ;[].forEach.call(document.querySelectorAll('a'), function (anchor) {
  268. // Some SSO links trigger an action
  269. if (anchor.href.substr(0, (locationHost + '/sso/').length) == locationHost + '/sso/') {
  270. var ssoPage = anchor.href.substr((locationHost + '/sso/').length).split('.')[0]
  271. if (['logout', 'delete', 'generate_password'].indexOf(ssoPage) > -1) {
  272. anchor.setAttribute('data-no-instant', '')
  273. }
  274. }
  275. else if (anchor.href.substr(0, (locationHost + '/gta/').length) == locationHost + '/gta/') {
  276. anchor.setAttribute('data-no-instant', '')
  277. }
  278.  
  279. // Visionneuse
  280. if (anchor.href.substr(0, (locationHost + '/screenshots/').length) == locationHost + '/screenshots/') {
  281. anchor.setAttribute('data-no-instant', '')
  282. }
  283. })
  284.  
  285. if (isInitialLoad) {
  286. var prospect = document.querySelector('#prospect')
  287. if (prospect) {
  288. prospect.setAttribute('hidden', '')
  289. }
  290.  
  291. var jv_footer = document.querySelector('#jv-footer')
  292. if (jv_footer) {
  293. checkFooterFilledInterval = setInterval(function() {
  294. if (jv_footer.children.length) {
  295. jv_footer.innerHTML = footerHtml
  296. clearInterval(checkFooterFilledInterval)
  297. }
  298. }, 100)
  299. }
  300. }
  301.  
  302. // Webedia backgrounds don’t play well when switching pages with Respeed, so let’s just disable them.
  303. ;[].forEach.call(document.querySelectorAll('style[id^=wads]'), function (adStyle) {
  304. adStyle.parentNode.removeChild(adStyle)
  305. })
  306. var backgroundAdClickElement = document.querySelector('#dds_clic')
  307. if (backgroundAdClickElement) {
  308. backgroundAdClickElement.parentNode.removeChild(backgroundAdClickElement)
  309. }
  310.  
  311. // Refresh
  312. if (!isInitialLoad && previousPage == location.pathname + location.search) {
  313. if (previousScroll) {
  314. scroll(0, previousScroll)
  315. }
  316. }
  317. previousPage = location.pathname + location.search
  318.  
  319. // Clear timer about slow site
  320. clearTimeout(slowSiteWarningTimer)
  321. removeSlowSiteWarning()
  322.  
  323. /* Stats page views */
  324. localStorage.RespeedStatsPageViews++
  325.  
  326.  
  327. /* Stats delay to click */
  328. if (!isInitialLoad && statsLastHover) {
  329. statsClicksMinusHovers.push((+new Date) - statsLastHover)
  330. statsLastHover = false
  331. if (statsLastMousedown) {
  332. statsClicksMinusMousedowns.push((+new Date) - statsLastMousedown)
  333. statsLastMousedown = false
  334. }
  335. processDelayStats()
  336. }
  337. }) // end on change
  338.  
  339.  
  340.  
  341. /***** ON WAIT *****/
  342.  
  343. InstantClick.on('wait', function() {
  344. clearTimeout(slowSiteWarningTimer)
  345. slowSiteWarningTimer = setTimeout(showSlowSiteWarning, 1000)
  346.  
  347. /* Stats delay to click */
  348. statsClicksMinusHovers.push((+new Date) - statsLastHover)
  349. statsLastHover = false
  350. if (statsLastMousedown) {
  351. statsClicksMinusMousedowns.push((+new Date) - statsLastMousedown)
  352. statsLastMousedown = false
  353. }
  354. processDelayStats()
  355. })
  356.  
  357.  
  358.  
  359. /***** ON CANCEL *****/
  360.  
  361. InstantClick.on('respeedcancel', function() {
  362. /* Stats delay to click */
  363. statsCancels.push((+new Date) - statsLastHover)
  364. processDelayStats()
  365. statsLastHover = false
  366. statsLastMousedown = false
  367. })
  368.  
  369.  
  370.  
  371. /***** ON FIRST PAGE *****/
  372.  
  373. ;[].forEach.call(document.querySelectorAll('link[rel=stylesheet]'), function (styleSheet) {
  374. var index = styleSheets.indexOf(styleSheet.getAttribute('href'))
  375. if (index > -1) {
  376. styleSheets[index] = ''
  377. }
  378. })
  379.  
  380. styleSheets.forEach(function(href) {
  381. if (!href) {
  382. return
  383. }
  384. var linkElement = document.createElement('link')
  385. linkElement.rel = 'stylesheet'
  386. linkElement.href = href
  387. linkElement.setAttribute('via-respeed', '')
  388. document.head.appendChild(linkElement)
  389. })
  390.  
  391. /*var jv_feedback = document.body.querySelector('#jv-feedback')
  392. if (jv_feedback) {
  393. document.body.removeChild(jv_feedback)
  394. }
  395. else {
  396. addEventListener('load', function() {
  397. document.body.removeChild(document.body.querySelector('#jv-feedback'))
  398. })
  399. }
  400. */
  401. var prospect_interstice = document.querySelector('#prospect-interstice')
  402. if (prospect_interstice) {
  403. prospect_interstice.setAttribute('hidden', '')
  404. }
  405.  
  406.  
  407. // Stylesheet
  408. var styleElement = document.createElement('style')
  409. styleElement.setAttribute('respeed', '')
  410.  
  411. // Respeed hides the top ad banner, which will sometimes provoke a bug with the ad script,
  412. // the banner will be floating on the page, to remedy to that we simply hide the banner.
  413. styleElement.innerHTML = 'div div a img[galleryimg] { display: none; }';
  414.  
  415. // Slow site warning toast
  416. styleElement.innerHTML += '@keyframes pulse { 40%, 60% { transform: scale(1.02); } }'
  417. styleElement.innerHTML += '@-webkit-keyframes pulse { 40%, 60% { -webkit-transform: scale(1.02); } }'
  418. styleElement.innerHTML += '#slowSiteWarningContainer { pointer-events: none; position: fixed; top: 9px; width: 100%; z-index: 1051; text-align: center; }'
  419. styleElement.innerHTML += '#slowSiteWarning { pointer-events: auto; cursor: default; right: 20px; display: inline-block; border: solid 1px rgba(0,0,0,.25); background: rgba(255,255,255,.9); color: #111; font-size: 13px; font-weight: bold; padding: 3px 9px; border-radius: 3px; animation: 200ms pulse ease-in-out; -webkit-animation: 200ms pulse ease-in-out; }'
  420.  
  421. // InstantClick bar
  422. styleElement.innerHTML += '#instantclick-bar { background: rgba(255,255,255,.9); }'
  423.  
  424. // Padding, as there isn’t the ad to do it anymore
  425. styleElement.innerHTML += '#content:not([style]) { padding-top: 20px; }'
  426.  
  427. document.head.appendChild(styleElement)
  428.  
  429.  
  430. // Stats
  431. // May someday be used to segment users and ask for feedback to the most active ones.
  432. if (!('RespeedStatsPageViews' in localStorage)) {
  433. localStorage.RespeedStatsPageViews = 0
  434. }
  435. if (!('RespeedStatsInstallDate' in localStorage)) {
  436. localStorage.RespeedStatsInstallDate = +new Date
  437. }
  438.  
  439.  
  440. document.querySelector('#RespeedScript').setAttribute('data-no-instant', '')
  441. // Without that, going back on the initial page through history would execute Respeed again
  442.  
  443.  
  444. /* Delete old localStorage variables */
  445. removeLocalStorageItems('RespeedStatsClicksMinusHovers', 'RespeedStatsCancels')
  446. removeLocalStorageItems('RespeedStatsClicksMinusHovers2', 'RespeedStatsClicksMinusMousedowns', 'RespeedStatsCancels2')
  447.  
  448.  
  449. /* Fetch delay stats from localStorage */
  450. if ('RespeedStatsClicksMinusHovers3' in localStorage) {
  451. statsClicksMinusHovers = localStorage.RespeedStatsClicksMinusHovers3.split(' ')
  452. }
  453. if ('RespeedStatsClicksMinusMousedowns3' in localStorage) {
  454. statsClicksMinusMousedowns = localStorage.RespeedStatsClicksMinusMousedowns3.split(' ')
  455. }
  456. if ('RespeedStatsMousewheelsMinusHovers3' in localStorage) {
  457. statsMousewheelsMinusHovers = localStorage.RespeedStatsMousewheelsMinusHovers3.split(' ')
  458. }
  459. if ('RespeedStatsCancels3' in localStorage) {
  460. statsCancels = localStorage.RespeedStatsCancels3.split(' ')
  461. }
  462. InstantClick.init()
  463.  
  464. } // end jeuxvideo.com block