GithubHelp home page GithubHelp logo

hejny / ukraine Goto Github PK

View Code? Open in Web Editor NEW
53.0 3.0 6.0 57.09 MB

Help Ukraine - add ribbon with Ukraine flag into the website you manage, show the anti-war message to Russian users, or block them from your service.

License: Apache License 2.0

JavaScript 3.40% TypeScript 96.60%
ukraine ukraine-invasion war ukrainewar typescript library

ukraine's Introduction

๐ŸŸฆ Stop war on Ukraine ๐ŸŸจ

Help Ukraine - add ribbon with Ukraine flag into the website you manage, show the anti-war message to Russian users, or block them from your service.

Wallpaper of ๐ŸŸฆ Stop war on Ukraine ๐ŸŸจ

A lot of companies did this in their custom way but this library is supereasy option to do for everyone.

๐ŸŽ—๏ธ Add ribbon with Ukraine flag on your website

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save({
        ribbon: 'TOP_LEFT',
        hasShadow: true,
        countries: [],
    });
</script>

image

Or use other method of installation see below.

โŽ I want to show banner for Russian users

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save({
        isCancelable: true,
    });
</script>

Or use other method of installation see below.

๐Ÿ›‘ I want to block website for Russian users

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save({
        isCancelable: false,
    });
</script>

image

Or use other method of installation see below.

๐Ÿฉธ I want to show banner for Russian users but not include cruel graphic and blood

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save({
        isBloodIncluded: false,
        isGraphicIncluded: false,
    });
</script>

image

Or use other method of installation see below.

๐ŸŽ—๏ธ๐ŸŽ—๏ธ๐ŸŽ—๏ธ๐ŸŽ—๏ธ I want to have ribbon in multiple corners

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save({
        ribbon: 'TOP_LEFT',
        hasShadow: true,
        countries: [],
    });
    Ukraine.save({
        ribbon: 'TOP_RIGHT',
        hasShadow: false,
        countries: [],
    });
    Ukraine.save({
        ribbon: 'BOTTOM_LEFT',
        hasShadow: true,
        countries: [],
    });
    Ukraine.save({
        ribbon: 'BOTTOM_RIGHT',
        hasShadow: false,
        countries: [],
    });
</script>

Or use other method of installation see below.

๐Ÿ“ฒ How to include on your page?

There are several ways how to add this to your page:

๐Ÿ“” Via HTML script tag

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save();
</script>

Note: Normally you would include async and defer keywords in the script element. But in this situation we do not want to defer this miniscript.

๐Ÿ“— Wordpress

Install Simple Custom CSS and JS WordPress plugin and add the following code as the Custom HTML:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js" integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/" crossorigin="anonymous"></script>
<script>
    Ukraine.save();
</script>

๐Ÿ“˜ Import into the bundle

First, you need to install save-ukraine package from NPM:

npm i save-ukraine

And then use:

import Ukraine from 'save-ukraine';

Ukraine.save();

Note: This library is written in TypeScript so options are fully typed.

โš›๏ธ React

First, you need to install save-ukraine package from NPM:

npm i save-ukraine

And then use:

import Ukraine from 'save-ukraine';

ReactDOM.render(
    <>
        <div
            ref={(element) => {
                if (!element) {
                    return;
                }
                Ukraine.save({ element, ...props });
            }}
        />
        {/*...Here will be rest of your app...*/}
    </>,
    document.getElementById('root'),
);

Or you can make full component:

// SaveUkraine.tsx

import * as React from 'react';
import Ukraine, { IUkraineOptions } from 'save-ukraine';

export function SaveUkraine(props: Partial<Omit<IUkraineOptions, 'element'>>) {
    return (
        <div
            ref={(element) => {
                if (!element) {
                    return;
                }
                Ukraine.save({ element, ...props });
            }}
        />
    );
}

And use it:

import { SaveUkraine } from './SaveUkraine';

ReactDOM.render(
    <>
        <SaveUkraine isCancelable={true} />
        {/*...Here will be rest of your app...*/}
    </>,
    document.getElementById('root'),
);

๐Ÿ› ๐Ÿงฉ Other customization

You can customize what will be shown. Here are all the options. If you have some idea feel free to contribute via pull request.

Ukraine.save({
    text: 'Stop the war with <b>Ukraine</b>',
    countries: [/* Russia and Belarus */ 'ru', 'by'],
    moreInfoUrl: `https://github.com/hejny/Ukraine`,
    ribbon: 'TOP_LEFT',
    isInConsole: true,
    isBloodIncluded: true,
    isGraphicIncluded: true,
    isCancelable: true,
});

๐Ÿ‘จ๐Ÿฝโ€๐Ÿ’ป Security

When you import anything (not only this script) on your page, please do not trust the publisher. Verify the code and include only the specific version not the wildcard of every future version.

โœ‰๏ธ Motivation

As a libertarian and programmer, I would never think that I would someday work on a piece of software that would go against free access to any service from any corner of the world.

But unfortunately, the situation has changed.

Ukraine was attacked by Russia and a lot of innocent children, women and men are now dying in Kyiv and other Ukrainian cities at the hands of one cruel dictator.

This can not be tolerated in 21. century in Europe.

We can not just close our eyes and just provide all services and benefits to the Russian economy which can keep killing innocent people.

If you are managing some website, please stop it for Russia until the war will be over and putin overthrown.


I don't want to punish the Russian people as a whole. As a citizen of Prague, I have few Russian friends and this definitely won't change. I believe most Russians do not support the politics of their state and especially this cruel war. But unfortunately, economic pressure is now one of the less bad solutions. And every ruble paid on taxes for the current Russian government means more money for killing innocent people.


I have created a simple way how to do it.

For the users from other places, nothing happens or ๐ŸŸฆ you can optionally place the ribbon with Ukraine flag ๐ŸŸจ. The script is tiny to load and insignificant. If the visitor is from Russia or Belarus (detected by system language) this message will appear:

๐Ÿ“› Make 3D printed bagge

276990939_10221763639026308_8401530540848276183_nhttps://www.thingiverse.com/thing:5326034

โ‰๏ธ FAQ

Few most common things aggregated from your questions:


How do you detect whether the user is or isn't from Russia.

We are capturing navigator.language from the browser. Full implementation is here.


How do you block the page?

I am putting a fixed full-screen div with a big z-index + restricting overflow and pointer-events for the rest of the page.


This restriction can be easily avoided!

Yes and no. For litter more skilled user on the desktop, it can be. For most of the users not. They can also switch their language but my goal is not to be bulletproof 100% blocking. But just to show this important message for Russian citizens.


This will also restrict Russian-speaking people from Ukraine?

Unfortunately, probably yes. Please do not place this for some essential services for Ukrainian people which can help them survive the war, like news, instructions, maps, ... There is no way how to perfectly detect who the user is and there will be always false positives and false negatives.

But if you have some better solution for this issue, please share with me.


It makes no sense to block western information from Russian people!

Definitely! If you are maintaining news and telling truth about the war / putin, please do not block it for the Russian people. This tool should be used as part of economic and social sanctions to Russia but made from the bottom. So, if you have some professional tool, some war/politics unrelated topic, unrelated blog, e-shop, crypto tool... you can use it as your personal economic sanctions.

Not to punish Russian people but to increase the efficiency of economic sanctions and help to get rid of the current Kremlin regime.


Can I change this and that?

Definitely! Please make a pull request.

ukraine's People

Contributors

hejny avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ukraine's Issues

Message unclear

The message "stop the war" is too vague and unclear. Also the translation reads "Stopping the war in Ukraine" and not stop the war.
According to Russian propaganda they already are stopping the war by waging the war(ill logic) so this message is about nothing. Need better targeted message.

CVE-2021-44906 (Medium) detected in minimist-1.2.5.tgz - autoclosed

CVE-2021-44906 - Medium Severity Vulnerability

Vulnerable Library - minimist-1.2.5.tgz

parse argument options

Library home page: https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz

Path to dependency file: /package.json

Path to vulnerable library: /node_modules/minimist/package.json

Dependency Hierarchy:

  • ts-jest-27.0.7.tgz (Root Library)
    • json5-2.2.0.tgz
      • โŒ minimist-1.2.5.tgz (Vulnerable Library)

Found in HEAD commit: 00c2b0044184130f87ecdce1346d0c7f3ac46650

Found in base branch: main

Vulnerability Details

Minimist <=1.2.5 is vulnerable to Prototype Pollution via file index.js, function setKey() (lines 69-95).

Publish Date: 2022-03-17

URL: CVE-2021-44906

CVSS 3 Score Details (5.0)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: High
    • Privileges Required: Low
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: Low

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://github.com/substack/minimist/issues/164

Release Date: 2022-03-17

Fix Resolution: minimist - 1.2.6


Step up your Open Source Security Game with WhiteSource here

Do not restrict Russian-speaking people from Ukraine

I just do not know how to achieve this?

  • By secondary geolocation or detection of UK in navigator.languages
  • By asking for users' GPS if the language is Russian?
  • Can I somehow be privacy-respecting (not asking external service) + without backend detecting users' IP from the frontend.

Do not broke node environment

In node environment this throws error on not finding a window - but for some users it can be confusing

import Ukraine from 'save-ukraine';

Ukraine.save();

Safari view problems

Glory to Ukraine and happy independence day from Kherson!

Safari, 4K 27', how to fix that empty spaces?

Thank you.

image

Avoid making part of the screen non-clickable

Because there is a <div> and only after the <a> with the rotation, it happens that the parent div covers a "transparent" part of the screen.

For instance, take this code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bug</title>
</head>

<body>
    <div style="background: black; width: 200px; height: 40px;" onclick="alert('miao')"></div>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/main.js"
        integrity="sha384-Xn1RAG80M8PZlBQh3r8fUvHY7c8RtuplSnqXOkdJyCxqRsToRwJ1m2FP7vyJo7u/"
        crossorigin="anonymous"></script>
    <script>
        Ukraine.save({
            ribbon: 'TOP_LEFT',
            hasShadow: true,
            countries: [],
        });
    </script>
</body>

</html>

You will see that if you click the black rectangle, it will not display any alert, because the ribbon's parent is obscuring it. In the image below, the covering div is with a purple boder:

image

A solution would be just to remove the superfluous div container and moving the first transform directly to the tag

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.