Filmweb Community Rating Redirector

Otwiera opinie/oceny znajomych w nowym osobnym okienku zamiast nadpisywać stronę filmu.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Filmweb Community Rating Redirector
// @namespace   https://greasyfork.org/pl/users/636724-cml99
// @match       http*://*filmweb.pl/film/*
// @match       http*://*filmweb.pl/serial/*
// @match       http*://*filmweb.pl/tvshow/*
// @match       http*://*filmweb.pl/videogame/*
// @version     1.2.0
// @author      CML99
// @license     CC-BY-NC-SA-4.0
// @description Otwiera opinie/oceny znajomych w nowym osobnym okienku zamiast nadpisywać stronę filmu.
// @description:en  Opens user opinions and friend ratings in a new separate window instead of replacing the current movie page.
// @icon        https://www.google.com/s2/favicons?sz=64&domain=filmweb.pl
// @grant       GM_xmlhttpRequest
// @grant       GM.xmlHttpRequest
// @grant       GM_addStyle
// ==/UserScript==


function openInPopup(url) {
  const features = 'width=800,height=600,resizable=yes,scrollbars=yes';
  window.open(url, '_blank', features);
}


var intvRedirectCommunity = setInterval(function() {
  var communityVotes = document.querySelectorAll('a[href$="/opinie#/community/popular"]');
  if (communityVotes.length < 1) {
    return false;
  }

  clearInterval(intvRedirectCommunity);

  document.querySelectorAll('a[href$="/opinie#/community/popular"]').forEach(function (link) {
    link.addEventListener('click', function (event) {
      event.preventDefault();
      openInPopup(this.href);
    });
  });
}, 5000);


var intvRedirectFriend = setInterval(function() {
  var friendVotes = document.querySelectorAll('a[href$="/opinie#/friends/votes"]');
  if (friendVotes.length < 1) {
    return false;
  }

  clearInterval(intvRedirectFriend);

  document.querySelectorAll('a[href$="/opinie#/friends/votes"]').forEach(function (link) {
    link.addEventListener('click', function (event) {
      event.preventDefault();
      openInPopup(this.href);
    });
  });
}, 5000);


var intvRedirectCritic = setInterval(function() {
  var criticVotes = document.querySelectorAll('a[href$="/opinie#/critics"]');
  if (criticVotes.length < 1) {
    return false;
  }

  clearInterval(intvRedirectCritic);

  document.querySelectorAll('a[href$="/opinie#/critics"]').forEach(function (link) {
    link.addEventListener('click', function (event) {
      event.preventDefault();
      openInPopup(this.href);
    });
  });
}, 5000);


var intvRedirectOpinion = setInterval(function() {
  var opinions = document.querySelectorAll('.opinionsSection .opinionBoxNew__commentLink');
  if (opinions.length < 1) {
    return false;
  }

  clearInterval(intvRedirectOpinion);

  document.querySelectorAll('.opinionsSection .opinionBoxNew__commentLink').forEach(function (link) {
    link.addEventListener('click', function (event) {
      event.preventDefault();
      openInPopup(this.href);
    });
  });
}, 2500);


GM_addStyle ( `
  .opinionBox__comment { pointer-events: none !important; }   /* disable critic link */
` );