Skip to content

Commit

Permalink
chore: disallow plugin usage for ruzzia
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Oct 10, 2022
1 parent 785764e commit b101973
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 92 deletions.
32 changes: 3 additions & 29 deletions src/SweetAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import { DismissReason } from './utils/DismissReason.js'
import Timer from './utils/Timer.js'
import { unsetAriaHidden } from './utils/aria.js'
import * as dom from './utils/dom/index.js'
import { setInnerHtml } from './utils/dom/index.js'
import { handleInputOptionsAndValue } from './utils/dom/inputUtils.js'
import { getTemplateParams } from './utils/getTemplateParams.js'
import { openPopup } from './utils/openPopup.js'
import defaultParams, { showWarningsForParams } from './utils/params.js'
import setParameters from './utils/setParameters.js'
import { callIfFunction, getRandomElement } from './utils/utils.js'
import { callIfFunction } from './utils/utils.js'

let currentInstance

Expand Down Expand Up @@ -259,34 +258,9 @@ const blurActiveElement = () => {
}
}

// This anti-war message will only be shown to Russian users visiting Russian sites
// Dear russian users visiting russian sites. Let's play a game.
if (typeof window !== 'undefined' && /^ru\b/.test(navigator.language) && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
if (Math.random() < 0.3) {
const noWar = document.createElement('div')
noWar.className = 'save-yourself-from-war'
const video = getRandomElement([
{
text: `Главная задача сейчас - не попасть на войну и помочь своим ближним не быть мобилизоваными.`,
id: 'X39ZkynPjpQ',
},
])
setInnerHtml(
noWar,
`<div>${video.text}</div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/${video.id}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<div>Сохраните себя и своих близких!</div>
`
)
const closeButton = document.createElement('button')
closeButton.innerHTML = '&times;'
closeButton.onclick = () => noWar.remove()
noWar.appendChild(closeButton)
window.addEventListener('load', () => {
setTimeout(() => {
document.body.appendChild(noWar)
}, 1000)
})
}
document.body.style.pointerEvents = 'none'
}

// Assign instance methods from src/instanceMethods/*.js to prototype
Expand Down
57 changes: 0 additions & 57 deletions src/scss/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -823,60 +823,3 @@ $icon-zoom: math.div(strip-units($swal2-icon-size), 5);
left: auto;
}
}

.save-yourself-from-war {
display: flex;
position: fixed;
z-index: 1939;
top: 0;
right: 0;
bottom: 0;
left: 0;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 25px 0 20px;
background: #20232a;
color: #fff;
text-align: center;

div {
max-width: 560px;
margin: 10px;
line-height: 146%;
}

iframe {
max-width: 100%;
max-height: calc(100vmin / 1.8);
margin: 16px auto;
}

strong {
border-bottom: 2px dashed white;
}

button {
display: flex;
position: fixed;
z-index: 1940;
top: 0;
right: 0;
align-items: center;
justify-content: center;
width: 48px;
height: 48px;
margin-right: 10px;
margin-bottom: -10px;
border: none;
background: transparent;
color: #aaa;
font-size: 48px;
font-weight: bold;
cursor: pointer;

&:hover {
color: #fff;
}
}
}
6 changes: 0 additions & 6 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,3 @@ export const asPromise = (arg) => (hasToPromiseFn(arg) ? arg.toPromise() : Promi
* @returns {boolean}
*/
export const isPromise = (arg) => arg && Promise.resolve(arg) === arg

/**
* @param {Array} arr
* @returns {any}
*/
export const getRandomElement = (arr) => arr[Math.floor(Math.random() * arr.length)]

0 comments on commit b101973

Please sign in to comment.