1

I'm having trouble making this extension do what I need it to do. I'm new to Chrome development, so I don't know if anything should show up in the JavaScript console on an error, but I can tell you that nothing shows up there. I don't know if the script is running or running but stops due to an error.

Manifest.json:

{
  "name": "SharePoint 2010 Welcome Email Disabler",
  "version": "1.0",
  "manifest_version": 2,

  "description": "Unchecks the 'Send welcome email to new users' checkbox when you add permissions in SharePoint 2010.",

  "content_scripts": [
    {
      "matches": ["http://omitted/*/_layouts/aclinv.aspx", "https://omitted/*/_layouts/aclinv.aspx"],
      "js": ["SP2010WelcomeEmailDisabler.user.js"],
      "all_frames": true,
      "run_at": "document_idle"
    }
  ],

  "permissions": [
    "http://omitted/"   
  ]
}

SP2010WelcomeEmailDisabler.user.js:

document.getElementById("ctl00_PlaceHolderMain_ifsSendEmail_chkSendEmail").checked = false;

I believe the issue lies in that the element I wish to modify is in an iframe that does not have a src tag (javascript loads its contents) and I'm not sure how to address the content inside the iframe.

If anyone has successfully accomplished this, I'd love a clue on how to proceed.

Thanks.

4
  • Does the iframe exist in the same domain as the parent page? If not, you will not be able to access the content due to security restrictions Jan 4, 2013 at 21:20
  • Yup, the iframe content is a .aspx file, but not via the src property of the iframe. The top frame and the iframe are served from the same folder (maybe one folder up or down from one another) of the same server.
    – Naikrovek
    Jan 5, 2013 at 0:34
  • @Naikrovek: What error does it show on console?
    – Sudarshan
    Jan 5, 2013 at 9:47
  • No error is shown; it just doesn't work. It is sad that in 2013 this is the state of web development. I gave up with this approach and created an accessibility CSS file for IE and will use IE for sharepoint work. When that particular checkbox is checked, a giant red border is applied to the checkbox.
    – Naikrovek
    Jan 5, 2013 at 23:28

1 Answer 1

1

You can try something like this, instead of trying to get the element directly. You can find it in the frames collection.

for(var i=0;i<frames.length;i++) 
{
  var frame = frames[i];  
  if(frame.document != 'undefined' && frame.document.getElementById('ctl00_PlaceHolderMain_ifsSendEmail_chkSendEmail') != null) {
    frame.document.getElementById('ctl00_PlaceHolderMain_ifsSendEmail_chkSendEmail').checked =       false;
  } 
} 
1
  • Doesn't work, but I flagged you as correct because I learned something. All I need is a way to easily see that I've forgotten to uncheck that box. The IE Accessibility CSS lets me set that one checkbox to have a 20px red border around it if I forget. I don't know enough about Chrome to make something similar happen there, or to use a user.js file to uncheck the box for me. Score 1 for IE I guess.
    – Naikrovek
    Jan 7, 2013 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.