element-web-patches/patches/remove-share-to-nonfree-services.sh

112 lines
3.4 KiB
Bash
Raw Normal View History

#!/bin/sh
# This file is part of the element-web-patches.
#
# element-web-patches is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# element-web-patches is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with element-web-patches. If not, see <https://www.gnu.org/licenses/>.
2024-09-14 19:05:29 -04:00
set -euo pipefail
LWD="$PWD"
echo "Removing links to nonfree services..."
error() {
echo "Failed to patch, exiting..."
exit 1
}
2024-09-14 19:05:29 -04:00
cd "${1}"
if test -f "./node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js"; then
patchjs_content=$(cat << EOF
--- a/node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js
+++ b/node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js
@@ -37,28 +37,6 @@
*/
const socials = [{
- name: "Facebook",
- img: require("../../../../res/img/social/facebook.png"),
- url: url => \`https://www.facebook.com/sharer/sharer.php?u=\${url}\`
-}, {
- name: "Twitter",
- img: require("../../../../res/img/social/twitter-2.png"),
- url: url => \`https://twitter.com/home?status=\${url}\`
-},
-/* // icon missing
- name: 'Google Plus',
- img: 'img/social/',
- url: (url) => \`https://plus.google.com/share?url=\${url}\`,
-},*/
-{
- name: "LinkedIn",
- img: require("../../../../res/img/social/linkedin.png"),
- url: url => \`https://www.linkedin.com/shareArticle?mini=true&url=\${url}\`
-}, {
- name: "Reddit",
- img: require("../../../../res/img/social/reddit.png"),
- url: url => \`https://www.reddit.com/submit?url=\${url}\`
-}, {
name: "email",
img: require("../../../../res/img/social/email-1.png"),
url: url => \`mailto:?body=\${url}\`
2024-09-14 19:05:29 -04:00
EOF
)
echo "${patchjs_content}" | patch -t -p1 || error
fi
if test -f ".${1}/src/components/views/dialogs/ShareDialog.tsx"; then
2024-09-14 19:05:29 -04:00
patchtsx_content=$(cat << EOF
--- a${1}/src/components/views/dialogs/ShareDialog.tsx
+++ b${1}/src/components/views/dialogs/ShareDialog.tsx
@@ -31,30 +31,6 @@
const socials = [
{
- name: "Facebook",
- img: require("../../../../res/img/social/facebook.png"),
- url: (url: String) => \`https://www.facebook.com/sharer/sharer.php?u=\${url}\`,
- },
- {
- name: "Twitter",
- img: require("../../../../res/img/social/twitter-2.png"),
- url: (url: string) => \`https://twitter.com/home?status=\${url}\`,
- },
- /* // icon missing
- name: 'Google Plus',
- img: 'img/social/',
- url: (url) => \`https://plus.google.com/share?url=\${url}\`,
- },*/ {
- name: "LinkedIn",
- img: require("../../../../res/img/social/linkedin.png"),
- url: (url: string) => \`https://www.linkedin.com/shareArticle?mini=true&url=\${url}\`,
- },
- {
- name: "Reddit",
- img: require("../../../../res/img/social/reddit.png"),
- url: (url: string) => \`https://www.reddit.com/submit?url=\${url}\`,
- },
- {
name: "email",
img: require("../../../../res/img/social/email-1.png"),
url: (url: string) => \`mailto:?body=\${url}\`,
EOF
)
2024-09-14 19:05:29 -04:00
echo "${patchtsx_content}" | patch -t -p1 || error
fi
cd $LWD