Dark Pita stands for Dark Pattern Intervention for Transparency and Awareness. A chrome extension aiming at intervention for dark patterns on websites.
# install dependencies
$ yarn
# build in dev mode
$ yarn dev
# build for production
$ yarn build
In order to test the package holding the extension in Chrome we need to:
- Go to
chrome://extensions/
page. - Toggle
Developer mode
ON. - Select
Load Unpacked
. - Select the
/dist
directory.
- Create or Go to the folder named by the site in
src/contents/components
. - Create a new folder named by your target dark pattern, e.g.
amazon/buy_now
. - Create a new file named by your alternative design, e.g.
/buy_now/amazon_buy_now_hide.vue
. - Copy the following to the new file.
<template>
<div></div>
</template>
<script>
export default {
data() {},
mounted() {
this.emitter.on('template', (message) => {
if (message === 'on') {
console.log('template on');
this.$emit('update');
} else if (message === 'off') {
console.log('template off');
this.$emit('update');
}
});
}
};
</script>
<style lang="scss" scoped></style>
- add the name of your targeted dark pattern in
data() {}
ofsrc/contents/App.vue
.
targetNames: {
...,
amazon_buy_now: false
}
- Import your alternative in
src/contents/App.vue
.
// Action components
import amazon_buy_now_hide from '@/contents/components/amazon/buy_now/amazon_buy_now_hide.vue';
- Register your alternative in
src/contents/App.vue
.
components: {
...,
amazon_buy_now_hide
}
- Add your alternative in
src/contents/App.vue
template.
<template>
<div id="DP_wrapper" :key="reload">
...
<amazon_buy_now_hide
v-if="targetNames.amazon_buy_now"
@update="generateOverviewOverlay"
/>
...
</div>
</template>
- Add your alternative in
data() {}
ofsrc/contents/components/basic/Action.vue
.
interventionState: {
...
amazon_buy_now_hide: 'off'
}
- Add your alternative in
alterIntervention(index)
ofsrc/contents/components/basic/Action.vue
.
alterIntervention(index) {
...
else if (this.intervention.component === 'amazon_buy_now_hide') {
this.emitter.emit('amazon_buy_now_hide', 'on');
}
...
},
- Now you can develop your alternative and test it by choosing and selecting in the action panel after you build and add the extension to Chrome.
❗Note: the name of your targeted dark pattern (e.g. amazon_buy_now) and the name of your alternatives for it (e.g. amazon_buy_now_hide) should be kept same across all files, including index.js
, App.js
, and Action.js
.
- Add relevant information about the target site and the dark patterns on it in
src/contents/index.js
. - Add the target site in
src/manifest.json
.
"content_scripts": [
{
"matches": [
"https://tailwindcss.com/*",
"https://twitter.com/*",
"https://www.amazon.com/*"
],
"js": ["contents/main.js"]
}
],
- Add the selector and import the information in
src/contents/App.vue
// Define the identifier
if (url.search(/tailwindcss.com/) !== -1) {
this.website = 'tailwind';
this.info = INDEX.tailwind;
} else if (url.search(/twitter.com/) !== -1) {
this.website = 'twitter';
this.info = INDEX.twitter;
} else if (url.search(/amazon.com/) !== -1) {
this.website = 'amazon';
this.info = INDEX.amazon;
}
// Set the selector
if (this.website === 'tailwind') {
element = document.getElementById(this.targets[i]);
} else if (this.website === 'twitter') {
element = document.querySelector('[aria-label="' + this.targets[i] + '"]');
} else if (this.website === 'amazon') {
element = document.querySelectorAll('[id^=' + this.targets[i] + ']')[0];
}