├── DiffBlocker.php ├── i18n └── en.json ├── extension.json └── SpecialAllowAnonDiffViewing.php /DiffBlocker.php: -------------------------------------------------------------------------------- 1 | getQueryValues()['oldid']) && $user->isAnon() && !$wgRequest->getSession()->exists('anondiffs')) { 7 | $result = ['diffblocker-login-required']; 8 | 9 | return false; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "diffblocker-login-required": "Please confirm you are a human to view differences between revisions by going to [[Special:AllowAnonDiffViewing|this form]].", 3 | "diffblocker-anon-diff-form-content": "Click the \"Allow\" button below to allow viewing differences between revisions.", 4 | "diffblocker-anon-diff-success": "Success! You can now view differences between revisions.", 5 | "allowanondiffviewing": "Allow Anonymous Diff Viewing" 6 | } -------------------------------------------------------------------------------- /extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 1, 3 | "name": "DiffBlocker", 4 | "author": ["Jacob G. (jvvg)"], 5 | "AutoloadClasses": { 6 | "DiffBlocker": "DiffBlocker.php", 7 | "SpecialAllowAnonDiffViewing": "SpecialAllowAnonDiffViewing.php" 8 | }, 9 | "HookHandlers": { 10 | "main": { 11 | "class": "DiffBlocker", 12 | "services": [ ] 13 | } 14 | }, 15 | "SpecialPages": { 16 | "AllowAnonDiffViewing": { 17 | "class": "SpecialAllowAnonDiffViewing" 18 | } 19 | }, 20 | "Hooks": { 21 | "getUserPermissionsErrors": "main" 22 | }, 23 | "MessagesDirs": { 24 | "DiffBlocker": [ 25 | "i18n" 26 | ] 27 | }, 28 | "manifest_version": 1 29 | } -------------------------------------------------------------------------------- /SpecialAllowAnonDiffViewing.php: -------------------------------------------------------------------------------- 1 | getOutput()->addHTML(Html::openElement('form', ['method' => 'post', $this->getPageTitle()->getLocalUrl()])); 13 | 14 | $this->getOutput()->addHTML( 15 | Html::rawElement( 16 | 'div', 17 | [], 18 | $this->msg('diffblocker-anon-diff-form-content')->parse() 19 | ) 20 | ); 21 | 22 | $this->getOutput()->addHTML( 23 | Html::element('button', ['type' => 'submit'], 'Allow') 24 | ); 25 | 26 | $this->getOutput()->addHTML(Html::closeElement('form')); 27 | } 28 | 29 | function handlePost() { 30 | $this->getRequest()->getSession()->persist(); 31 | $this->getRequest()->getSession()->set('anondiffs', 'true'); 32 | 33 | $this->getOutput()->addHTML($this->msg('diffblocker-anon-diff-success')->parse()); 34 | } 35 | 36 | function execute($par) { 37 | $this->getOutput()->setPageTitle( $this->msg( "allowanondiffviewing" )->escaped() ); 38 | 39 | if ($this->getRequest()->wasPosted()) { 40 | $this->handlePost(); 41 | } else { 42 | $this->showForm(); 43 | } 44 | } 45 | } --------------------------------------------------------------------------------