Created
October 12, 2018 00:40
-
-
Save khsk/104de799d85d2aa90478ad18357295bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Qiita report spam issue | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description ワンクリックでスパム報告 | |
// @author khsk | |
// @include https://qiita.com/*/items/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const ul = document.getElementsByClassName('dropdown-menu dropdown-menu-right'); | |
if (!ul) { | |
return; | |
} | |
const li = document.createElement('li'); | |
const a = document.createElement('a'); | |
const span = document.createElement('span'); | |
span.className = 'fa fa-fw fa-flag'; | |
span.setAttribute('aria-hidden', 'true'); | |
span.textContent = ' スパム報告'; | |
a.insertBefore(span, a.firstChild); | |
li.appendChild(a); | |
ul[0].appendChild(li); | |
a.addEventListener('click', () => { | |
const spam = document.querySelector('#public_issue_report_reason_spam'); | |
if (spam.nextSibling.textContent !== ' スパムです ') { | |
console.log(spam.nextSibling.textContent) | |
return; | |
} | |
document.querySelector('#public_issue_report_reason_spam').checked = true; | |
document.querySelector('.btn.btn-primary.reportForm_submitButton').click(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment